Hi i am trying to check whether my RadioButton is checked or not in a method.If checked execute some code else execute another code.
But when i debug it I am getting this error
Object reference not set to an instance of an object
I have gone through many links but not able to correct it.
Below is my .aspx.cs code
public static string[] GetArea(string prefixText, int count)
{
RadioButton rb1 = RadioButton2;
if (rb1.Checked == true)
{
//execute some code
//return some value;
}
else
{
//execute some other code
//return some value;
}
}
RadioButton2 is defined in my .aspx page
I am getting error at this line
Code
if (rb1.Checked == true)Please help.Thankyou
Manas MohapatraRank #182 · 13.2K reputationPosted Jan 10, 2016, 11:01 PM EST
KAJAL TANEJA21 reputationPosted Jan 10, 2016, 11:05 PM EST
Ravi PatelRank #439 · 5.7K reputationPosted Jan 10, 2016, 11:06 PM EST
KAJAL TANEJA21 reputationPosted Jan 10, 2016, 11:09 PM EST
Manas MohapatraRank #182 · 13.2K reputationPosted Jan 10, 2016, 11:14 PM EST
KAJAL TANEJA21 reputationPosted Jan 10, 2016, 11:33 PM EST
Ravi PatelRank #439 · 5.7K reputationPosted Jan 10, 2016, 11:38 PM EST
KAJAL TANEJA21 reputationPosted Jan 10, 2016, 11:48 PM EST
narasimman g146 reputationPosted Jan 11, 2016, 7:12 PM EST
KAJAL TANEJA21 reputationPosted Jan 11, 2016, 9:59 PM EST
narasimman g146 reputationPosted Jan 11, 2016, 11:18 PM EST
Rojalin SahooRank #2,919 · 493 reputationPosted Jan 12, 2016, 1:42 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts