Copied to clipboard

Flag this post as spam?

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


  • Nicolas 26 posts 46 karma points
    Nov 16, 2011 @ 17:39
    Nicolas
    0

    Umbraco and postback value in a ASP.NET page?

    Hello,

    I try to do something really simple that perfectly works on a normal page. In my masterpage, I've got a updatePanel. Inside, there is a asp textbox and an asp button, plus an asp literal. When you click on the button, it fires an event that take the value of the textbox and put it in the literal.

    protected void onClick(object sender, EventArgs e)    {
            testLiteral.Text = testTexbox.Text;
        }

     

    This easy code works well. But when transferring the exact same logic into an Umbraco masterpage, it's stop working. It look like that the value of testTexbox was overide during the postback. It's tried to use Request.Form and umbraco.library.RequestForm with no success.

    There is something in the live cycle of the page that brakes my logic, but I can't find it. Can you help me? Thanks!

  • Phil 12 posts 32 karma points
    Nov 16, 2011 @ 21:33
    Phil
    0

    Not sure why you would want to do this, but should be sinple enough to implement using a user control. Have a look in the Umbraco TV section.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 16, 2011 @ 21:38
    Jan Skovgaard
    0

    Hi Nicolas

    What does the content of your masterpage look like? I suspect you probably have a server side form <form runat="server"> sorounding all the content on the page, which is probably why it's not working. But please post the code and let's have a closer look :)

    /Jan

  • Rodion Novoselov 694 posts 859 karma points
    Nov 18, 2011 @ 07:24
    Rodion Novoselov
    0

    Hi. I've just tried it - and for me it works ok. Here's my snippet:

    <form runat="server">
      <asp:ScriptManager runat="server"/>
      <asp:UpdatePanel runat="server">
        <ContentTemplate>
          <asp:TextBox ID="tb" runat="server"/>
          <asp:Button runat="server" OnClick="btn_Click" Text="Submit"/>
          <br/>
          <asp:Literal ID="lit" runat="server"/>
        </ContentTemplate>
      </asp:UpdatePanel>
    </form>
      
    <script runat="server">
      void btn_Click(object sender, EventArgs e) {
        lit.Text = tb.Text;
      }
    </script>

    Try to check the settings of your ScriptManager and UpdatePanel so that they allow partial page updates and the UpdatePanel is updated on a button click.

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Nov 18, 2011 @ 08:43
    Richard Soeteman
    0

    Hi,

    Umbraco masterpage is no different than a normal masterpage. Make sure all elements are in a form tag with the runat=server attribute, also make sure you don't have another form runat=server tag on your page and set causesvalidation on your button to false. It could be that "something" is validating the page and blocking the request.

    Cheers,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft