Hi,
Hi , I have a varible sem,which takes inputfrom the textbox but if the textbox is kept empty i want it to return "Please Enter a Semester"
int sem;
int parsevalue;
if (int.TryParse(TextBox2.Text, out parsevalue))
{
sem = parsevalue;
Session["Sem"] = sem;
}
else
{
Literal2.Text = "Please Enter a Semester";
}
But If the Textbox is empty the Session["Sem"]
returns NullExceptionError
in the .aspx
file where i have used it.
I searched for the proper conversion using tryparse but could not understand it clearly as to how to print the above mentioned error message. please help Thank you in advance