Link to home
Start Free TrialLog in
Avatar of mainrotor
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
Avatar of JosephEricDavis
JosephEricDavis

Maybe we need a little more detail on what your after.

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.
Avatar of Sara bhai
you can use

Response.write("<script>alert('successfully');</script>");
ASKER CERTIFIED SOLUTION
Avatar of Rick
Rick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.RegisterStartupScript(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:ScriptManager>
Avatar of mainrotor

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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_OnClick" />
    </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.RegisterStartupScript(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.