Re: Client side action to cause postback

Discussion in 'ASP .Net' started by Vidar Petursson, Jul 11, 2003.

  1. Hi

    As soon as anything is added to the textbox set radio checked and submit?

    myBox.Attributes.Add("onkeypress","if(this.value != '')
    {this.form.myRadio.checked=true; this.form.submit()}");

    Note if radiobtn list then you have to use index
    this.form.myRadio[INDEX].checked = true;

    Is checkbox not a better choice than radio

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "Antonio Maciel" <> wrote in message
    news:e%...
    > Hi.
    >
    > I have a client-side script associated with the onKeyPress event of a
    > textbox. When my user types any character on the textbox I need to check a
    > radiobutton and causes a postback to the server. I tried this expression
    > txtPostalCode.Atributes.Add("onKeyPress",
    > "document.Form1.rbSelection.checked=true; return true;"). The radiobutton

    is
    > checked but no postback occurs. How can I raise a postback from this code?
    >
    > Thanks,
    >
    > Antonio Maciel
    >
    >
     
    Vidar Petursson, Jul 11, 2003
    #1
    1. Advertising

  2. Hi Vidar.

    Your code works, but as soon as the form is submited the value of the
    textbox is lost. Do you have any idea on why?

    Thanks,

    Antonio Maciel.

    "Vidar Petursson" <> wrote in message
    news:%...
    > Hi
    >
    > As soon as anything is added to the textbox set radio checked and submit?
    >
    > myBox.Attributes.Add("onkeypress","if(this.value != '')
    > {this.form.myRadio.checked=true; this.form.submit()}");
    >
    > Note if radiobtn list then you have to use index
    > this.form.myRadio[INDEX].checked = true;
    >
    > Is checkbox not a better choice than radio
    >
    > --
    > Best Regards
    > Vidar Petursson
    > ==============================
    > Microsoft Internet Client & Controls MVP
    > ==============================
    > "Antonio Maciel" <> wrote in message
    > news:e%...
    > > Hi.
    > >
    > > I have a client-side script associated with the onKeyPress event of a
    > > textbox. When my user types any character on the textbox I need to check

    a
    > > radiobutton and causes a postback to the server. I tried this expression
    > > txtPostalCode.Atributes.Add("onKeyPress",
    > > "document.Form1.rbSelection.checked=true; return true;"). The

    radiobutton
    > is
    > > checked but no postback occurs. How can I raise a postback from this

    code?
    > >
    > > Thanks,
    > >
    > > Antonio Maciel
    > >
    > >

    >
    >
     
    Antonio Maciel, Jul 11, 2003
    #2
    1. Advertising

  3. Hi

    ahh.... use onkeyup instead of onkeypress


    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "Antonio Maciel" <> wrote in message
    news:...
    > Hi Vidar.
    >
    > Your code works, but as soon as the form is submited the value of the
    > textbox is lost. Do you have any idea on why?
    >
    > Thanks,
    >
    > Antonio Maciel.
    >
    > "Vidar Petursson" <> wrote in message
    > news:%...
    > > Hi
    > >
    > > As soon as anything is added to the textbox set radio checked and

    submit?
    > >
    > > myBox.Attributes.Add("onkeypress","if(this.value != '')
    > > {this.form.myRadio.checked=true; this.form.submit()}");
    > >
    > > Note if radiobtn list then you have to use index
    > > this.form.myRadio[INDEX].checked = true;
    > >
    > > Is checkbox not a better choice than radio
    > >
    > > --
    > > Best Regards
    > > Vidar Petursson
    > > ==============================
    > > Microsoft Internet Client & Controls MVP
    > > ==============================
    > > "Antonio Maciel" <> wrote in message
    > > news:e%...
    > > > Hi.
    > > >
    > > > I have a client-side script associated with the onKeyPress event of a
    > > > textbox. When my user types any character on the textbox I need to

    check
    > a
    > > > radiobutton and causes a postback to the server. I tried this

    expression
    > > > txtPostalCode.Atributes.Add("onKeyPress",
    > > > "document.Form1.rbSelection.checked=true; return true;"). The

    > radiobutton
    > > is
    > > > checked but no postback occurs. How can I raise a postback from this

    > code?
    > > >
    > > > Thanks,
    > > >
    > > > Antonio Maciel
    > > >
    > > >

    > >
    > >

    >
    >
     
    Vidar Petursson, Jul 11, 2003
    #3
  4. Vidar Petursson

    David Waz... Guest

    why not just set the AutoPostback=True on the radio button?


    "Vidar Petursson" <> wrote in message
    news:...
    > Hi
    >
    > ahh.... use onkeyup instead of onkeypress
    >
    >
    > --
    > Best Regards
    > Vidar Petursson
    > ==============================
    > Microsoft Internet Client & Controls MVP
    > ==============================
    > "Antonio Maciel" <> wrote in message
    > news:...
    > > Hi Vidar.
    > >
    > > Your code works, but as soon as the form is submited the value of the
    > > textbox is lost. Do you have any idea on why?
    > >
    > > Thanks,
    > >
    > > Antonio Maciel.
    > >
    > > "Vidar Petursson" <> wrote in message
    > > news:%...
    > > > Hi
    > > >
    > > > As soon as anything is added to the textbox set radio checked and

    > submit?
    > > >
    > > > myBox.Attributes.Add("onkeypress","if(this.value != '')
    > > > {this.form.myRadio.checked=true; this.form.submit()}");
    > > >
    > > > Note if radiobtn list then you have to use index
    > > > this.form.myRadio[INDEX].checked = true;
    > > >
    > > > Is checkbox not a better choice than radio
    > > >
    > > > --
    > > > Best Regards
    > > > Vidar Petursson
    > > > ==============================
    > > > Microsoft Internet Client & Controls MVP
    > > > ==============================
    > > > "Antonio Maciel" <> wrote in message
    > > > news:e%...
    > > > > Hi.
    > > > >
    > > > > I have a client-side script associated with the onKeyPress event of

    a
    > > > > textbox. When my user types any character on the textbox I need to

    > check
    > > a
    > > > > radiobutton and causes a postback to the server. I tried this

    > expression
    > > > > txtPostalCode.Atributes.Add("onKeyPress",
    > > > > "document.Form1.rbSelection.checked=true; return true;"). The

    > > radiobutton
    > > > is
    > > > > checked but no postback occurs. How can I raise a postback from this

    > > code?
    > > > >
    > > > > Thanks,
    > > > >
    > > > > Antonio Maciel
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    David Waz..., Jul 11, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Blair
    Replies:
    1
    Views:
    622
  2. Shadow_>>>

    Does the mailto: action cause spam

    Shadow_>>>, Apr 6, 2004, in forum: HTML
    Replies:
    3
    Views:
    491
    Hywel
    Apr 6, 2004
  3. Boss302
    Replies:
    0
    Views:
    1,056
    Boss302
    Nov 21, 2006
  4. Bogdan
    Replies:
    2
    Views:
    655
    Bogdan
    Jun 9, 2008
  5. Zoe Hart
    Replies:
    1
    Views:
    373
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page