MessageBox
-
It appears that you are missing and '=' between language and javascript. Instead of using Response.Write perhaps you should register a startup script.
private void ShowDialog(string p_msg)
{
Type cstype = this.GetType();
StringBuilder tmpSB = new StringBuilder();
tmpSB.Append("");tmpSB.Append("alert('" + p_msg + "')");
tmpSB.Append("");
ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString());
}Hope that helps. Ben
Hi Ben Thanks for the Reply, here is the code protected void cancelRec(object sender, EventArgs e) { ShowDialog("test"); } private void ShowDialog(string p_msg) { Type cstype = this.GetType(); StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); tmpSB.Append("alert('" + p_msg + "')"); tmpSB.Append(""); ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString()); } But its not working. Nor throwing any error. Any idea? Thanks Cheers Menon
-
Hi Ben Thanks for the Reply, here is the code protected void cancelRec(object sender, EventArgs e) { ShowDialog("test"); } private void ShowDialog(string p_msg) { Type cstype = this.GetType(); StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); tmpSB.Append("alert('" + p_msg + "')"); tmpSB.Append(""); ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString()); } But its not working. Nor throwing any error. Any idea? Thanks Cheers Menon
The message box will only pop up after the page posts back. Is your CancelRec getting called? What are you really trying to do? I am guessing that since the method is called cancel rec you perhaps want to prompt the user before they cancel? If that is the case you want to do something complete different with javascript. If that is the case let me know and I can show you the code. Ben
-
Hi Ben Thanks for the Reply, here is the code protected void cancelRec(object sender, EventArgs e) { ShowDialog("test"); } private void ShowDialog(string p_msg) { Type cstype = this.GetType(); StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); tmpSB.Append("alert('" + p_msg + "')"); tmpSB.Append(""); ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString()); } But its not working. Nor throwing any error. Any idea? Thanks Cheers Menon
Hey mady1380 could you please tel me the scenario so that we can help you better.
Regards, Sandeep Kumar.V
-
The message box will only pop up after the page posts back. Is your CancelRec getting called? What are you really trying to do? I am guessing that since the method is called cancel rec you perhaps want to prompt the user before they cancel? If that is the case you want to do something complete different with javascript. If that is the case let me know and I can show you the code. Ben
Hi Ben I am sorry about the code. Actually i put the code in the CancelButton just to test. I want it on the click of Savebutton. I am creating textboxes dynamically. And I want to throw Error via Messagebox if the Textbox is empty. Thats it. It still appreciate your help still.. Thanks Cheers Menon
-
Hi Ben I am sorry about the code. Actually i put the code in the CancelButton just to test. I want it on the click of Savebutton. I am creating textboxes dynamically. And I want to throw Error via Messagebox if the Textbox is empty. Thats it. It still appreciate your help still.. Thanks Cheers Menon
-
Hey mady1380 could you please tel me the scenario so that we can help you better.
Regards, Sandeep Kumar.V
Hi Sandeep I am Creating Textbox dynamically. I am making a check if the Textbox is null I want to Throw an Error via MessageBox. I dont want it Onclick of button. I want to display the MessageBox on particular condition. Eg: if(txtName.Text=="") ShowDialog("Name Cannot Be Empty");//MESSAGE BOX I hope its clear. Thanks Cheers Menon
-
Are you using .net 2.0? The code I posted was for .net 2.0 it is slightly different for .net 1.0 or 1.1. If you are using .net 2.0 then it should work. You could always do a more pure javascript solution. Ben
-
Well then if you can verify in debug mode that the code behind is getting hit. If that is happening when that page comes back up, the question would be do you have pop up blockers that might be blocking the message box? You can always check the source of the page with View source. You should see the javascript toward the bottom of the page. At this point I would be guess that it is either a pop up blocker or the code behind isn't getting hit or something like that. Ben
-
Hi Sandeep I am Creating Textbox dynamically. I am making a check if the Textbox is null I want to Throw an Error via MessageBox. I dont want it Onclick of button. I want to display the MessageBox on particular condition. Eg: if(txtName.Text=="") ShowDialog("Name Cannot Be Empty");//MESSAGE BOX I hope its clear. Thanks Cheers Menon
mady1380 wrote:
I want to display the MessageBox on particular condition.
could you please sepicify a condition?? like when you want to test textbox is null or not.....
Regards, Sandeep Kumar.V
-
mady1380 wrote:
I want to display the MessageBox on particular condition.
could you please sepicify a condition?? like when you want to test textbox is null or not.....
Regards, Sandeep Kumar.V