asp.net the MessageBox control in the development of your heart
Source: Internet
Author: User
Asp.net| controls that make you asp.net the MessageBox control in development
Believe that the use of ASP.net to do web developers, will miss the use of MessageBox.Show ("") Information tips. Unfortunately, this type of functional function is not supported in ASPX, and at best, alert ("") is used in the script to achieve the goal. If you want to control the display of the client Information prompt form in the server-side code, you can't control it directly.
Here is a Web custom control that I designed and developed to control the client information prompt form on the server side.
It is very simple to operate, the code is very small, I believe you will be satisfied with the use of it!
You only need to set the Text property of the control in the server-side code. You can see on the client the information you need to prompt the form, it is more desirable that the Text property is stateless, that is, the next postback process without any further action can be automatically implemented hidden.
To put it simply, you only need to assign a value to the Text property when you want it to be displayed, and you can do it automatically without assigning it.
And there's one thing you should be aware of is the position of the control in the ASPX page, which is generally recommended to be positioned at the end of the page, so that you can jump out of the informational dialog box after everything is displayed, otherwise the content of the other pages placed behind the control will be temporarily hidden.
The following is a list of the source code for the control:
//********************************************
Using System;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.ComponentModel;
Namespace Basicwebcontrol.messagebox
{
<summary>
Summary description of the Alertbox.
</summary>
[Defaultproperty ("Text"), ToolBoxData ("<{0}:alertbox runat=server></{0}:alertbox>")]
public class AlertBox:System.Web.UI.Control
{
private string text = String. Empty;
<summary>
What's displayed, note that you cannot include single or double quotes
</summary>
[Bindable (True), Category ("appearance"), DefaultValue ("")]
public string Text
{
Get
{
return text;
}
Set
{
Text = value;
}
}
<summary>
///
</summary>
Public Alertbox ()
{
}
<summary>
Renders this control to the specified output parameter.
</summary>
<param name= "Output" > HTML writer to write </param>
protected override void Render (HtmlTextWriter output)
{
if (Text!= string. Empty)
{
Output. Write ("<script language= ' JavaScript ' >alert");
Output. Write (Text);
Output. Write ("');</script>");
}
}
}
}
//********************************************
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service