Click here to Skip to main content
16,021,823 members
Please Sign up or sign in to vote.
3.00/5 (1 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.

U can use ModalPopupExtender of Ajax Extension....

The script of the ModalPopupExtender is as follows:

XML
<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....
C#
{
    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..

C#
protected void hideModalPopupViaServer_Click(object sender, EventArgs e)
{
    this.programmaticModalPopup.Hide();
}
 
Share this answer
 
v2
Comments
Bikash Shrestha From Nepal 21-Oct-10 3:45am    
yo Jipin ,good one
sweeneel 21-Oct-10 3:51am    
gud solution hunter,.............
Please check the following tutorial which might help:

http://www.4guysfromrolla.com/articles/021104-1.aspx[^]
 
Share this answer
 
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.







 
Share this answer
 
Another link here[^].
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900