radio button

Discussion in 'ASP .Net' started by Claudia Fong, Sep 12, 2007.

  1. Claudia Fong

    Claudia Fong Guest

    I have a radio button list in webform1 and a button. This button when
    clicks, it will open another webform2 which will get the value of the
    radio button selected in my first web form.

    The problem is that webform2 is the start page.. so when the program
    starts, it will give me an error:

    Object reference not set to an instance of an object

    in this line --> str = Request.Params["radioButton"].ToString();

    If I set a default value in the radio button will it work? And how can I
    set a default value in the radio button?

    Cheers!

    Claudi

    *** Sent via Developersdex http://www.developersdex.com ***
    Claudia Fong, Sep 12, 2007
    #1
    1. Advertising

  2. On Sep 12, 10:36 am, Claudia Fong <> wrote:
    > I have a radio button list in webform1 and a button. This button when
    > clicks, it will open another webform2 which will get the value of the
    > radio button selected in my first web form.
    >
    > The problem is that webform2 is the start page.. so when the program
    > starts, it will give me an error:
    >
    > Object reference not set to an instance of an object
    >
    > in this line --> str = Request.Params["radioButton"].ToString();
    >
    > If I set a default value in the radio button will it work? And how can I
    > set a default value in the radio button?
    >


    Why do you need two pages here? All this can be done within the one
    webform
    Alexey Smirnov, Sep 12, 2007
    #2
    1. Advertising

  3. Claudia Fong

    Claudia Fong Guest

    Because the second webpage will act as a pop-up window for the user to
    select the other language.
    Default language is in english but user is able to change to other
    language


    Cheers!

    Claudi

    *** Sent via Developersdex http://www.developersdex.com ***
    Claudia Fong, Sep 12, 2007
    #3
  4. On Sep 12, 11:27 am, Claudia Fong <> wrote:
    > Because the second webpage will act as a pop-up window for the user to
    > select the other language.
    > Default language is in english but user is able to change to other
    > language


    hm, okay

    > in this line --> str = Request.Params["radioButton"].ToString();


    Try to check it

    if (Request.Params["radioButton"] != null) {
    str = Request.Params["radioButton"].ToString();
    } else {
    str = "English";
    }
    Alexey Smirnov, Sep 12, 2007
    #4
  5. Claudia Fong

    Claudia Fong Guest

    if (Request.Params["radioButton"] != null)
    {
    str = Request.Params["radioButton"].ToString();
    }
    else
    {
    str = "en-US";
    }

    With this, it will work the first time I load the page, but when I
    select another language, it will still go to the code in the else
    scope... and it should go to this line

    str = Request.Params["radioButton"].ToString();

    :(

    Cheers!

    Claudi

    *** Sent via Developersdex http://www.developersdex.com ***
    Claudia Fong, Sep 12, 2007
    #5
  6. Claudia Fong

    Claudia Fong Guest

    Claudia Fong, Sep 12, 2007
    #6
  7. On Sep 12, 12:43 pm, Claudia Fong <> wrote:
    > if (Request.Params["radioButton"] != null)
    > {
    > str = Request.Params["radioButton"].ToString();
    > }
    > else
    > {
    > str = "en-US";
    > }
    >
    > With this, it will work the first time I load the page, but when I
    > select another language, it will still go to the code in the else
    > scope... and it should go to this line
    >
    > str = Request.Params["radioButton"].ToString();
    >
    > :(
    >
    > Cheers!
    >
    > Claudi
    >
    > *** Sent via Developersdexhttp://www.developersdex.com***


    Because Request.Params["radioButton"] does not exist I guess.

    on webform1 you have to set radioButton to Request.Params and do

    Server.Transfer("webform2.aspx");

    if it doesn't work, share all your code here
    Alexey Smirnov, Sep 12, 2007
    #7
    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. Scott D Johnson
    Replies:
    1
    Views:
    1,065
    Scott D Johnson
    Sep 27, 2006
  2. Jan C. Faerber
    Replies:
    0
    Views:
    619
    Jan C. Faerber
    Jun 30, 2009
  3. tshad
    Replies:
    6
    Views:
    6,968
    Alexey Smirnov
    Nov 26, 2009
  4. Martin
    Replies:
    8
    Views:
    3,346
    Jan C. Faerber
    Nov 24, 2009
  5. Hiten
    Replies:
    1
    Views:
    620
    Vidar Petursson
    May 26, 2004
Loading...

Share This Page