Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Cesar Labarca 7 posts 27 karma points
    May 11, 2012 @ 21:47
    Cesar Labarca
    0

    In .NET User Control, IsPostback allways False

    Hello all,

    I have a fairly basic Umbraco site set up and everything works fine. I added a .NET user control that has a drop-down with autopost set to true and an onindexchange event in the code-behind. The control renders properly, but I am finding out that the IsPostBack property allways evaluates to False in the code. No matter what I do, no matter how I wrap the control, IsPostBack evaluates to false.

    If I wrap the user control in a <form runat=server> tag, then the control functions properly (IsPostBack is correct) but nothing else functions (most likely because this creates nested <Form> tags).

    What needs to be in place or configured in what fashion for the user control IsPostBack property to evaluate correctly?

    Have been at this problem for days. Any help would be greatly appreciated.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 13, 2012 @ 13:03
    Jeroen Breuer
    0

    In asp.net you can only have 1 form which has runat=server. All you webcontrol need to be in there. If you place another form in that form it won't work. So the best solution is to change your code so it has 1 big form with runat=server around the entire website and remove all other forms.

    Jeroen

  • Cesar Labarca 7 posts 27 karma points
    May 14, 2012 @ 17:10
    Cesar Labarca
    0

    Thanks for your reply Jeroen.  I was aware of that limitation.  I placed the <Form> tag in the user control as a test. 

    Maybe I can turn the question around; if one were to require that IsPostBack is always false for a user control, what would need to be done?

    I suspect that I have something configured incorrectly somewhere, but I have no idea where to look and I need just a slight push in the right direction.

     

    Thanks,


    Cesar

  • Cesar Labarca 7 posts 27 karma points
    May 15, 2012 @ 23:58
    Cesar Labarca
    0

    Hello Gurus,

    I have solved the problem.

    If you have a LinkButton control anywhere in the masterpage (or any content contained in the masterpage) OR you have any control that has the PostBackURL property set, the asp.net viewstate breaks. Then, IsPostBack will not work.

    I went through all of my masterpage templates and all of my custom code, removed 3 PostBackURL assignments, and voila! It all works.

    Thanks,

    Cesar

     

Please Sign in or register to post replies

Write your reply to:

Draft