locked
What is equivalent to component class of windows forms to that of asp.net? RRS feed

  • Question

  • I was doing a project where i was using custom controll(component class) of windows forms to achive my requirements, now suddenly the project has been changed to asp.net where i have to perform the same operation. Im new to asp.net so i dont know which control to use in replacement to the custom controll. I tried using the asp.net server controll but im unable to do that. Is there any other way?
    Wednesday, July 4, 2012 10:36 AM

Answers

  • You need to reference the class library where Server controls are from the ASP.NET web site or web application project. Once you've done that and build the projects, you need to register server controls either on page where you want to use it or in web.config file.

    See following page for walkthrough http://msdn.microsoft.com/en-us/library/yhzc935f.

    And to learn more about ASP.NET, you should post your ASP.NET related questions to forums at http://forums.asp.net/.

    Stateless in ASP.NET and web generally means that the state is not saved between requests, if you don't do so by yourself, nothing to do with Cor's statement about static members although that is true also. Stateless comes at cost that you need to save the state of you controls between the requests, because every request creates new control instance; that's something you don't need to think in desktop applications.

    • Edited by MasaSam Thursday, July 5, 2012 10:38 AM
    • Proposed as answer by Mike Feng Friday, July 6, 2012 7:18 AM
    • Marked as answer by Mike Feng Monday, July 9, 2012 2:23 AM
    Thursday, July 5, 2012 10:30 AM

All replies

  • you need to use server control , in case of custom control you need to port your Windows forms custom control to ASP.Net Custom controls in fact there is there is no direct mapping , you may reuse business logic but you need to rewrite the entire UI 

    Ashwini

    Wednesday, July 4, 2012 11:23 AM
  • Ashwini:

      I have tried to use server control, but im not able to add it to my already created asp project? But i can create server controll in a whole new different project. Can u tell me how to include the server controll to my already existing asp project?

    Any help would be really appreciated.

    Wednesday, July 4, 2012 1:19 PM
  • which ASP version, and Dot.Net framework you are using , 

    Did you tried placing control on ASP.Net form 

    Wednesday, July 4, 2012 1:26 PM
  • Ashwini:

    Im not able to place controll in my asp.net form.

    Thanks.

    Thursday, July 5, 2012 5:20 AM
  • Hello,

    Controls in Windows Forms are complete different from controls in Asp.Net or and WPF they are made to be rendable to HTML/XML

    (Therefore you see also no dispose method on these controls)

    Be aware component class is not a kind of .Net base class, in fact it is a kind of intermediate to go from Win32 to .Net and if not needed not used anymore.

    (In the top of the hierarchies you see direct the VB6 compatibility namespace)

    http://msdn.microsoft.com/en-us/library/system.componentmodel.component.aspx

    There is in Windows Forms a WPF container.

    There is also an ASP.Net windows forms container, but that was intended in 2002 to be used, but in those days is was already only possible to use in situations where better direct Windows Forms could be used. On the web it failed then already because all security restrictions, it never passes a virus checker or even the web browsers (all brands).

    Therefore going from an Windows Forms application to ASP.Net means completely rewrite your user interface layer. (If you have done your program well you can use your Class Libraries). 

    Be aware that an ASP.Net program is stateless, it means that for instance not in a session saved data is released after a post to the client. Also be aware that all static (shared) data is shared by all users busy with the application.


    Success
    Cor





    Thursday, July 5, 2012 5:34 AM
  • Cor:

    Your reply is not specific. Im asking for asp.net web controlls. Im not clear from your reply.  Can u be specific about the web based controlls. Im in real need to convert a windows based user controll to a web based user control. Any link or related help would be really appreciated.

    Thanks and Regards,

    S. Vikneshwar


    Thursday, July 5, 2012 8:08 AM
  • You need to reference the class library where Server controls are from the ASP.NET web site or web application project. Once you've done that and build the projects, you need to register server controls either on page where you want to use it or in web.config file.

    See following page for walkthrough http://msdn.microsoft.com/en-us/library/yhzc935f.

    And to learn more about ASP.NET, you should post your ASP.NET related questions to forums at http://forums.asp.net/.

    Stateless in ASP.NET and web generally means that the state is not saved between requests, if you don't do so by yourself, nothing to do with Cor's statement about static members although that is true also. Stateless comes at cost that you need to save the state of you controls between the requests, because every request creates new control instance; that's something you don't need to think in desktop applications.

    • Edited by MasaSam Thursday, July 5, 2012 10:38 AM
    • Proposed as answer by Mike Feng Friday, July 6, 2012 7:18 AM
    • Marked as answer by Mike Feng Monday, July 9, 2012 2:23 AM
    Thursday, July 5, 2012 10:30 AM

  • Stateless in ASP.NET and web generally means that the state is not saved between requests, if you don't do so by yourself, nothing to do with Cor's statement about static members although that is true also. Stateless comes at cost that you need to save the state of you controls between the requests, because every request creates new control instance; that's something you don't need to think in desktop applications.

    I forgot to write a whole sentence which was probably in my mind but did not reach the text :-)  (also changed the first sentence)

    Corrected it in the message



    Thanks
    Cor


    Friday, July 6, 2012 8:03 AM
  • I made more mistakes in the text. 

    However, this sentence is maybe the most important part in my message for you.

    There is also an ASP.Net windows forms container, but that was intended in 2002 to be used, but in those days is was already only possible to use in situations where better direct Windows Forms could be used. On the web it failed then already because all security restrictions, it never passes a virus checker or even the web browsers (all brands).

    Therefore going from an Windows Forms application to ASP.Net means completely rewrite your user interface layer. (If you have done your program well you can use your Class Libraries). 

    But in fact your question is completely off topic here, I replied because I did not know a better forum for your question where people would know about all the kind of controls there are. Some think like you that they act all the same, that is what I tried the explain. For the WebControls visit like MasaSam already wrote the Asp.Net forums. 


    Success
    Cor

    Friday, July 6, 2012 8:09 AM