Question Received:
How to add the popup messageBox in the ASP.Net Web Page.Solution:
First, Add a new panel over the current page. Panel should hold themessageBox. It will be refreshed or updated whenever it renders the
messageBox.
In the 'default.aspx' page, Register the Control Page by,
<%@ Register
Src="~/MessageBox.ascx"
TagName="uscMsgBox"
TagPrefix="usc" %>
<asp:Content ID="BodyContent"
runat="server"
ContentPlaceHolderID="MainContent">
<usc:uscMsgBox ID="uscMessageBox"
runat="server" />
</asp:Content>
In the 'default.aspx.cs' page, Use the methods like,
--> uscMessageBox.AddMessage(message [NameSpace].MessageBox.enmMessageType.Error);
--> uscMessageBox.AddMessage(message [NameSpace].MessageBox.enmMessageType.Info);
Add the App_Themes with default.css, icons.
Now compile, It will work.
If Need, You can give the handler to 'OK' Button.
i. First, write control code in the 'MessageBox.ascx.cs' page.
protected void btnOK_Click(object sender, EventArgs e)
{
if (ClickedOK != null)
{
ClickedOK(this, new MsgBoxEventArgs(enmAnswer.OK, Args));
Args = "";
}
}
ii. Add the Handler Event to the 'default.aspx.cs' page.
uscMessageBox.ClickedOK += OKClick;
iii. Write handler in the 'default.aspx.cs' page.
public void OKClick(object sender, [NameSpace].MessageBox.
MsgBoxEventArgs e)
{
if (confirmContinue)
{
confirmContinue = false;
Response.Redirect("default.aspx");
}
}
iv. Please make changes in the 'Message.ascx.cs' page.
OnPreRender()
//ModalPopUpExtender_OKButton
mpeMsg.OkControlID = "btnD2";
Download source from, YaBu.MessageBox.zip
[Note:] Do above four steps if You want any handler to 'OK' Button.
No comments:
Post a Comment