0

I have this requirement for my project. Already there is an existing windows form application, Which sends email when a button is clicked. There's a lot of code behind the application. It validates the field serial number which is a text box by connecting to database. The validation error pops up as another windows form. It generates a report form after sending an email. There's a configuration button which is accessible only to particular users which opens configuration form which has details of email settings.

Now All this is developed using windows forms. My new requirement is i need to develop the same in a ASP.NET web page having similar functionality. I tried using click once deployment, but that's not they needed. they want it as a webpage.

Is there any tool or way i can show the application in ASP.NET web page? Do i need to start the coding from scratch?

Thanks in advance

Kcvin
  • 5,073
  • 2
  • 32
  • 54
user3332414
  • 21
  • 1
  • 6
  • Yes you might have to start from scratch as the validations and other functions will use different methods and you will have to divide code between client and server. Furthermore you will host your webpage on a server. – Rex Oct 13 '14 at 17:26

2 Answers2

0

As to what Rex said, you are going to have to start from scratch. The coding behind it is different. Validation and functions work differently in asp.net than they do in .net.

Travis
  • 135
  • 2
  • 10
0

You will have to start from scratch for reasons already mentioned. If this is your first ASP.net application here are a few tips for what you want to do:

1- For validation and transfer to the email report to work in a similar way you can use Response.Redirect or Server.Transfer or JavaScript. All of those methods have pros and cons, see Server.Transfer Vs. Response.Redirect for an example of the first two. For javascript you'll need to write a javascript function in the .aspx file or inject javascript in the page with response.write.

2- If you validate with JavaScript you also need to validate server side to make sure someone doesn't try to pass bad values to you. JavaScript can be disabled and users can call your report page and configuration page directly, while with windows forms you control that flow you don't on webpages.

3- You'll probably have to use CSS to style elements in your email configuration form and in your initial form. Positioning, docking, anchoring and so on is completely different in webpage and done with CSS. Have fun learning the CSS boxing model, what absolute positioning is, and what clear and float do ;)

4- The most important thing is that the Web is stateless. You can't use private members to keep information between page reload on the web. When you pass a value between 2 pages the first one doesn't exist anymore so you can't just do Class.somemembervariable as usual. Check out what viewstate, sessionstate and querystring are. When your page reload, without these, everything is loss. Clicking a server-side button cause the page to reload, which you need to handle (it's called postback). This also implies that when you serve the report page you will have to pass some Id for the email and check the user, so when you call the 2nd page you need to pass to it some id so it can work. I spent more time on this one because it's the most important difference between asp.net and windows form.

5- For restricting access to your email settings page you will probably need to use windows authentification if this is an Intranet site or Forms authentification if this is an Internet site. Check Starting ASP.NET Forms Authentication for some basic overview.

6- ASP.Net has a codebehind file where you write the actual code, and an .aspx page where you put the html tags, javascript, styles, and data binding with <%= %> tags.

7- You will probably have to work with IIS as well to make your website work unless you work at a very formal place where specific peoples take care of that. At the very basic you'll have to create an application pool, make it compatible with 32/64 bits and set up authentification in IIS.

Community
  • 1
  • 1
Mystra007
  • 275
  • 1
  • 9