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 HorvatRank #792 · 2.9K reputationPosted Jul 8, 2011, 1:19 AM EDT
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
anjumathi kumar54 reputationPosted Jul 8, 2011, 1:28 AM EDT
it schowing tlike this javascript run time error sir
Zoran HorvatRank #792 · 2.9K reputationPosted Jul 8, 2011, 1:34 AM EDT
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
Zoran HorvatRank #792 · 2.9K reputationPosted Jul 8, 2011, 4:19 AM EDT
Zoran