mainrotor
asked on
I need help using message boxes in ASP.Net 3.5
Hi Experts,
How are MessageBoxes used in ASP.Net 3.5? Can anyone please provide
Thanks in advance,
mrotor
How are MessageBoxes used in ASP.Net 3.5? Can anyone please provide
Thanks in advance,
mrotor
you can use
Response.write("<script>al ert('succe ssfully'); </script>" );
Response.write("<script>al
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If all you are going for is a javascript alert to pop up on the page that you trigger from the code behind, then a cleaner way of doing it is like this...
ScriptManager.RegisterStar tupScript( this, this.GetType(), "showPopupMessage", "alert('Your Message');", true);
You would just need to include a ScriptManager control in the markup of your page in order to do this.
<asp:ScriptManager runat="server" ID="scrptMngr"></asp:Scrip tManager>
ScriptManager.RegisterStar
You would just need to include a ScriptManager control in the markup of your page in order to do this.
<asp:ScriptManager runat="server" ID="scrptMngr"></asp:Scrip
ASKER
In my application I have a TextBox where the user enters a Record Number. When the user clicks on a button, I query the DataBase using the Record Number provided by the user. If the Record Number is not found, I want to use a PopupMessage that Prompts the user to enter a correct Record Number, wiith the "OK" button.
regards,
mrotor
regards,
mrotor
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the reason why i didnt use Response.write is, if u r going to use updatepanel, response.write wil make problems
An update panel would definitely be the right way to go in this case.
In the aspx file you can add mark up similar to this...
<asp:ScriptManager runat="server" ID="scrptMngr" />
<asp:UpdatePanel runat="server" ID="upCheckID" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox runat="server" ID="txtID" />
<asp:Button runat="server" ID="btnCheckID" OnClick="btnCheckID_OnClic k" />
</ContentTemplate>
</asp:UpdatePanel>
Then in the code behind you can add code similar to this...
protected void btnCheckID_OnClick(object sender, EventArgs e)
{
//Code to check the database id
if (your conditional logic)
{
ScriptManager.RegisterStar tupScript( this, this.GetType(), "showPopup", "alert('Your Message');", true);
}
}
The update panel will capture the button click and fire off the asynchronous request to your sever to run your database query and then if necessary return the startup script to display your message box.
In the aspx file you can add mark up similar to this...
<asp:ScriptManager runat="server" ID="scrptMngr" />
<asp:UpdatePanel runat="server" ID="upCheckID" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox runat="server" ID="txtID" />
<asp:Button runat="server" ID="btnCheckID" OnClick="btnCheckID_OnClic
</ContentTemplate>
</asp:UpdatePanel>
Then in the code behind you can add code similar to this...
protected void btnCheckID_OnClick(object sender, EventArgs e)
{
//Code to check the database id
if (your conditional logic)
{
ScriptManager.RegisterStar
}
}
The update panel will capture the button click and fire off the asynchronous request to your sever to run your database query and then if necessary return the startup script to display your message box.
Here is a page that might be on track with what your after.
http://www.codeproject.com/KB/webforms/AspNetMsgBox.aspx
Let us know if this is what you're going for of if it is something else. If it is something else, please elaborate.