protected void btnConnect_Click(object sender, EventArgs e)
{
try
{
dbquery.getconnection(txtsname.Text, txtuname.Text, txtpwd.Text);
pnlDB.Visible = true;
pnlCN.Visible = true; ddlDB();
}
catch (Exception ex)
{
lblex.Visible = true; string p = ex.Message.ToString();
Response.Write("");
lblex.Text = p;
pnlDB.Visible = false; pnlCN.Visible = true; }
}
I tried to connect server ..its not correct info it want to show error msg in alert box serverside
How to show the catch error in alertbox in server side
Loading
Zoran HorvatPosted Jul 8, 2011, 8:19 AM
Zoran
Zoran HorvatPosted Jul 8, 2011, 5:34 AM
string message = p.Replace('"', '\'');
message = message.Replace("\n", "\\n");
message = message.Replace("\r", "\\r");
string encoded = Server.HtmlEncode(message);
...
Try now. If it doesn't work, please try to open HTML source of the page and to attach it here.
Zoran
anjumathi kumarPosted Jul 8, 2011, 5:28 AM
it schowing tlike this javascript run time error sir
Zoran HorvatPosted Jul 8, 2011, 5:19 AM
You should enclose p in double quotes and ensure that it does not contain double quotes itself. You should also HTML encode it. So basically that might look like this:
string message = p.Replace('"', '\'');
string encoded = Server.HtmlEncode(message);
Response.Write("");
I think that should be sufficient to show error popup at the client.
Zoran