Click here to Skip to main content
14,578,910 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi there

Can anyone tell me why doesnt MsgBox() work in asp.net...For some my websites it works.but in some cases it shows error.....
Is there any alternate way to use message box other than javascript???
Or wat should additionally add to get MsgBox() work?
Should I include any other properties or namespaces?
Thank you in advance
Posted
Comments
NMehta83 21-Oct-10 2:32am
   
I am not sure but MsgBox() is the function which you made to show the alert message OR MsbBox() is the private method at server side code to show the message like MessageBox in the windows application. Please add your MsgBox() code here in your question to get the better idea. Edit your question and add your MsgBox() code.
Rate this:
Please Sign up or sign in to vote.

Solution 4

U can use ModalPopupExtender of Ajax Extension....

The script of the ModalPopupExtender is as follows:

<asp:ScriptManager id="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Button ID="hiddenTargetControlForModalPopup" runat="server" Style="display: none" />
    <ajaxToolkit:ModalPopupExtender ID="programmaticModalPopup" runat="server" BackgroundCssClass="modalBackground"

        BehaviorID="programmaticModalPopupBehavior" DropShadow="True" PopupControlID="programmaticPopup"

        PopupDragHandleControlID="programmaticPopupDragHandle" RepositionMode="RepositionOnWindowScroll"

        TargetControlID="hiddenTargetControlForModalPopup">
    </ajaxToolkit:ModalPopupExtender>
    <asp:Panel ID="programmaticPopup" runat="server" CssClass="modalPopup" Style="display: none;
        width: 350px; padding: 10px">
        <asp:Panel ID="programmaticPopupDragHandle" runat="Server" Style="cursor: move; background-color: #DDDDDD;
            border: solid 1px Gray; color: Black; text-align: center;">
            Status
        </asp:Panel>
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
<asp:Label id="lblStatusMessage" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
        </asp:UpdatePanel>
        <asp:Button ID="OkButton" runat="server" OnClick="hideModalPopupViaServer_Click"

            Text="OK" Width="58px" />
        <br />
        </asp:Panel>


Then to use the ModalPopupExtender whereever u want u can use the code below....
{
    this.lblStatusMessage.Text="Message Here";
    this.programmaticModalPopup.Show();
}

Note-> Dont forget to add the following code in ur code behind file to make the Messagebox disappear when the ok button is clicked..

protected void hideModalPopupViaServer_Click(object sender, EventArgs e)
{
    this.programmaticModalPopup.Hide();
}
   
v2
Comments
Bikash Shrestha From Nepal 21-Oct-10 3:45am
   
yo Jipin ,good one
sweeneel 21-Oct-10 3:51am
   
gud solution hunter,.............
Rate this:
Please Sign up or sign in to vote.

Solution 1

Please check the following tutorial which might help:

http://www.4guysfromrolla.com/articles/021104-1.aspx[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

What kind of message box your using...


If talking about Windows MessageBox.Show, then it will work for windows application only...


Using MessageBox.Show() in web apps will work, but it only displays on the server.

The reason for this is that the server is where your code is being processed.


To get this to work on the client side you need to use code that is processed on the client side, like javascript.







   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Another link here[^].
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100