• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Any ASP.NET 2 Experts here?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Any ASP.NET 2 Experts here?

    I can't believe how inflexible and generally tulipe ASP.NET 2.0 is.

    Problem is this...

    Building a page with loads of dynamic controls (images, hyperlinks, checkboxes, buttons etc. etc.).

    Some of these controls need event handlers for clicks etc.

    Ok. Me creates EventHandler and += it to the Click event, say.

    Trouble is, when I click the dynamic control, I get the postback, but it doesn't fire my event handler.

    Googled for hours on this, and many have the same problem but no solution seems to exist. This worked in ASP.NET 1.1. MS does not acknowledge it as a bug!

    WTF do I do now - and don't say use a GridView
    Last edited by bogeyman; 27 October 2006, 11:45.

    You've come right out the other side of the forest of irony and ended up in the desert of wrong.

    #2
    This is a bugger when it does that.

    Some hints...

    - Have you got AutoEventWireUp="True" in the @Page directive?

    - Are you binding the events in the constructor of the page class or the Page_Load event (which isn't being fired?).

    - Is the page a partial class?

    - Have you marked them as AutoPostBack="true"? <-- possibly this one!
    Serving religion with the contempt it deserves...

    Comment


      #3
      Make sure you recreate the dynamic controls on every postback and that they are created in the Init event and not page load.

      Comment


        #4
        Originally posted by TheMonkey
        This is a bugger when it does that.

        Some hints...

        - Have you got AutoEventWireUp="True" in the @Page directive?

        - Are you binding the events in the constructor of the page class or the Page_Load event (which isn't being fired?).

        - Is the page a partial class?

        - Have you marked them as AutoPostBack="true"? <-- possibly this one!
        Thanks for the pointers Monkey.

        In answer...

        1) Yes
        2) No (the controls are added in an event handler for another control - but this worked fine in ASP 1.1)
        3) Yes
        4) Yes

        In ASP.NET 2 it seems that Click (etc.) events will only fire for webcontrols you've actually placed on the webform at design time.

        By the time you hit postback, the dynamic control just doesn't exist, no matter how you set it up beforehand. You can pick up the name of the clicked control in the Page_Load() but that's about it.

        Maybe this is down to ASP 2's new and improved (i.e. straightjacketed, overengineered and crushingly-inflexible) webform events model.

        You've come right out the other side of the forest of irony and ended up in the desert of wrong.

        Comment


          #5
          I have previously posted that although .NET 2.0 is great, ASP.NET 2.0 is absolute tulipe. Complex, inflexible, confusing, counter intuitive, incomplete, inconsistent and generally a pain in the arse.

          I'm sure the PHP crowd are loving ASP.NET 2.0 release.

          Comment


            #6
            I think DimPrawn has the idea.

            I built something tha dynamically built a form once which was seriously just a big pain in the arse.

            I developed my own MVC architecture for use with ASP.Net that intercepts stuff using an HttpModule and does stuff nicely.
            Serving religion with the contempt it deserves...

            Comment


              #7
              Originally posted by DimPrawn
              I have previously posted that although .NET 2.0 is great, ASP.NET 2.0 is absolute tulipe. Complex, inflexible, confusing, counter intuitive, incomplete, inconsistent and generally a pain in the arse.

              I'm sure the PHP crowd are loving ASP.NET 2.0 release.

              Yes, I wrote a corresponding web app using PHP5 in about 4 days for my backend webservice.

              So far, the ASP.NET 2.0 version has taken me 10 days and still doesn't work properly.

              It's not practical for me to recreate all the dynamic controls and rebind the events on postback, and I can't be feckin bothered.

              ASP.NET 2 is UTTER tulipE. How the hell does anyone ever write webapps of something approaching complexity in ASP 2?

              If all you want to do is run a SQL query and fill a gridview, fine - if you want to do anything remotely unusual then you're fecked! Thank you MS, you tossers

              You've come right out the other side of the forest of irony and ended up in the desert of wrong.

              Comment


                #8
                Don't worry it's all fixed in ASP.NET 3.0

                Honest

                Comment


                  #9
                  Originally posted by bogeyman
                  Yes, I wrote a corresponding web app using PHP5 in about 4 days for my backend webservice.

                  So far, the ASP.NET 2.0 version has taken me 10 days and still doesn't work properly.

                  It's not practical for me to recreate all the dynamic controls and rebind the events on postback, and I can't be feckin bothered.

                  ASP.NET 2 is UTTER tulipE. How the hell does anyone ever write webapps of something approaching complexity in ASP 2?

                  If all you want to do is run a SQL query and fill a gridview, fine - if you want to do anything remotely unusual then you're fecked! Thank you MS, you tossers
                  Not really with you, whats wrong with recreating?
                  What would you like asp.net to do with things it knows nothing about (remember the web is stateless), maybe you want the server to cache all dynamic controls and hookups for an indefinate period just in case one of them is needed later????)
                  whats the lowest you can do this for?

                  Comment


                    #10
                    Ok I just tried that on .Net 2.0 SDK and it doesn't work there either.

                    For f*cks sake.
                    Serving religion with the contempt it deserves...

                    Comment

                    Working...
                    X