Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: ASP.net Not able to display error using label control

Nikhil G:

I am getting an Error while trying to display an error message using Label control on asp.net form

what I am trying to do:

I want to show an error message using a Label control, if a user click on Submit button without selecting an option given in dropdown control and textbox control.

What I have done:

I have put code on .aspx is lblControl.Visible="true" and code on aspx.cs is inside Page_load- if(!isPostBack){ lblControl.Visible="false";

Then where I have handled the click->


if((txtbox.Text == "") & (ddlbox.SelectedItem.Text == "Select"))
{
string Message = "Please select a value in drop down list, other than 'Select' and fill some value in text box.";
lblControl.Visible = true;
lblControl.Text = Message;
/* I have tried this one code also
Page.ClientScript.RegisterStartupScript(this.GetType(), "errMsg", script, true); //doesn't help */
}
else{
save(); //another method to perform insert operation.
}

What is happening now: (As per my debug observation) Whenever I am trying to display error message in the form of Label(control). The flow of program goes to Master page rather than display of Error message.


At the master we have placed various links related to show `logo image, ` logout link` etc `inside `

From there, debugging has halted & page has rendered without the message of lblContorl.

Confusion-cum-question: I am unable to understand this code-switch (flow of code getting child pages to Master pages)

many thanks for all types of suggestion!



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: ASP.net Not able to display error using label control

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×