Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   radio button (http://www.velocityreviews.com/forums/t536644-radio-button.html)

Claudia Fong 09-12-2007 08:36 AM

radio button
 
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 ***

Alexey Smirnov 09-12-2007 08:47 AM

Re: radio button
 
On Sep 12, 10:36 am, Claudia Fong <cdolphi...@yahoo.co.uk> 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


Claudia Fong 09-12-2007 09:27 AM

Re: radio button
 
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 ***

Alexey Smirnov 09-12-2007 10:09 AM

Re: radio button
 
On Sep 12, 11:27 am, Claudia Fong <cdolphi...@yahoo.co.uk> 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";
}


Claudia Fong 09-12-2007 10:43 AM

Re: radio button
 
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 09-12-2007 10:54 AM

Re: radio button
 
Is working now.. sorry about that....

Cheers!

Claudi

*** Sent via Developersdex http://www.developersdex.com ***

Alexey Smirnov 09-12-2007 10:58 AM

Re: radio button
 
On Sep 12, 12:43 pm, Claudia Fong <cdolphi...@yahoo.co.uk> 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



All times are GMT. The time now is 12:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.