Stop AutoPostBack

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    Stop AutoPostBack

    ASP.NET 2.0
    Visual Studio 2008

    I have the following code and when the textbox displays and I press Enter
    while in the text box I get AutoPostBack, how do I stop AutoPostBack?

    TextBox txt = new TextBox();
    txt.MaxLength = parm.MaxLength;
    txt.ID = parm.ParameterN ameID;
    txt.Text = "12345";
    txt.EnableViewS tate = true;
    txt.AutoPostBac k = false;
    this.PlaceHolde r1.Controls.Add (txt);



    Thank You


    Peter


  • Peter

    #2
    Re: Stop AutoPostBack

    Never mind, it's working, I don't know why it did not work before.

    "Peter" <pczurak@nospam .nospamwrote in message
    news:uiP1gYbfIH A.1900@TK2MSFTN GP02.phx.gbl...
    ASP.NET 2.0
    Visual Studio 2008
    >
    I have the following code and when the textbox displays and I press Enter
    while in the text box I get AutoPostBack, how do I stop AutoPostBack?
    >
    TextBox txt = new TextBox();
    txt.MaxLength = parm.MaxLength;
    txt.ID = parm.ParameterN ameID;
    txt.Text = "12345";
    txt.EnableViewS tate = true;
    txt.AutoPostBac k = false;
    this.PlaceHolde r1.Controls.Add (txt);
    >
    >
    >
    Thank You
    >
    >
    Peter
    >

    Comment

    • Peter

      #3
      Re: Stop AutoPostBack

      ASP.NET 2.0
      Visual Studio 2008

      I have the following code and when the textbox displays and I press Enter
      while in the text box I get AutoPostBack, how do I stop AutoPostBack?

      If I add another textbox (not in the PlaceHoder) the AutoPostback does get
      disabled in the txt control, but if there are no other text boxes on the
      form the txt control allways does the AutoPostback


      TextBox txt = new TextBox();
      txt.MaxLength = parm.MaxLength;
      txt.ID = parm.ParameterN ameID;
      txt.Text = "12345";
      txt.EnableViewS tate = true;
      txt.AutoPostBac k = false;
      this.PlaceHolde r1.Controls.Add (txt);



      "Peter" <pczurak@nospam .nospamwrote in message
      news:ugHWsfbfIH A.1900@TK2MSFTN GP02.phx.gbl...
      Never mind, it's working, I don't know why it did not work before.
      >
      "Peter" <pczurak@nospam .nospamwrote in message
      news:uiP1gYbfIH A.1900@TK2MSFTN GP02.phx.gbl...
      >ASP.NET 2.0
      >Visual Studio 2008
      >>
      >I have the following code and when the textbox displays and I press Enter
      >while in the text box I get AutoPostBack, how do I stop AutoPostBack?
      >>
      >TextBox txt = new TextBox();
      >txt.MaxLengt h = parm.MaxLength;
      >txt.ID = parm.ParameterN ameID;
      >txt.Text = "12345";
      >txt.EnableView State = true;
      >txt.AutoPostBa ck = false;
      >this.PlaceHold er1.Controls.Ad d(txt);
      >>
      >>
      >>
      >Thank You
      >>
      >>
      >Peter
      >>
      >
      >

      Comment

      • marss

        #4
        Re: Stop AutoPostBack

        On 4 âÅÒ, 07:33, "Peter" <pczu...@nospam .nospamwrote:
        I have the following code and when the textbox displays and I press Enter
        while in the text box I get AutoPostBack, how do I stop AutoPostBack?
        Hi Peter,

        This behaviour is not caused by value of AutoPostBack property of a
        TextBox, it is default browser's reaction to pressing Enter key.
        I posted some thoughts on this topic here:

        Maybe you'll find it useful.

        Regards,
        Mykola

        Comment

        • Peter

          #5
          Re: Stop AutoPostBack

          Thank you very much!

          It certainly explains what was going on.


          "Peter" <pczurak@nospam .nospamwrote in message
          news:uiP1gYbfIH A.1900@TK2MSFTN GP02.phx.gbl...
          ASP.NET 2.0
          Visual Studio 2008
          >
          I have the following code and when the textbox displays and I press Enter
          while in the text box I get AutoPostBack, how do I stop AutoPostBack?
          >
          TextBox txt = new TextBox();
          txt.MaxLength = parm.MaxLength;
          txt.ID = parm.ParameterN ameID;
          txt.Text = "12345";
          txt.EnableViewS tate = true;
          txt.AutoPostBac k = false;
          this.PlaceHolde r1.Controls.Add (txt);
          >
          >
          >
          Thank You
          >
          >
          Peter
          >

          Comment

          • Peter

            #6
            Re: Stop AutoPostBack

            I have tried the Convenience #1 Item #3 from the
            http://marss.co.ua/UnexpectedPostback.aspx but the page still gets submitted
            when I press the enter key and the focus is in the text box. Regardless how
            many Textboxes or Input fields I have on the webpage, pressing Enter key
            submits the page.

            The only time I can get it to work is if I use UseSubmitBehavi or="False",
            but then FCKEditor control does not post it's value, so I can not use that.

            Any other suggestions I can try?

            "marss" <marss.ua@gmail .comwrote in message
            news:e845d3f2-cc24-477d-b6e4-60d80b96bca7@2g 2000hsn.googleg roups.com...
            On 4 âÅÒ, 07:33, "Peter" <pczu...@nospam .nospamwrote:
            I have the following code and when the textbox displays and I press
            Enter
            while in the text box I get AutoPostBack, how do I stop AutoPostBack?
            Hi Peter,

            This behaviour is not caused by value of AutoPostBack property of a
            TextBox, it is default browser's reaction to pressing Enter key.
            I posted some thoughts on this topic here:

            Maybe you'll find it useful.

            Regards,
            Mykola



            Comment

            • marss

              #7
              Re: Stop AutoPostBack

              I have tried the Convenience #1 Item #3 from thehttp://marss.co.ua/UnexpectedPostb ack.aspxbut the page still gets submitted
              when I press the enter key and the focus is in the text box. Regardless how
              many Textboxes or Input fields I have on the webpage, pressing Enter key
              submits the page.
              >
              The only time I can get it to work is if I use UseSubmitBehavi or="False",
              but then FCKEditor control does not post it's value, so I can not use that.
              >
              Two different situations are described there, and the attempt to solve
              situation #2 by one of the solutions for situation #1 is not very good
              idea.

              As I see you can avoid the postback if you set
              btnSubmit.UseSu bmitBehavior="F alse", where btnSubmit is a button which
              submits the form to the server.
              Concerning output HTML it is replacement of <input type='submit'by
              <input type='button'>. If you want <input type='button'al so submits
              the form
              you have to add a handler for onclick event:

              btnSubmit.Attri butes["onclick"] = "document.f orms[0].submit();"

              Try, maybe it will help. That is all that I can suggest, I do not
              familiar with FCKEditor and can't give more concrete advice.

              Mykola

              Comment

              Working...