MessageBox control in developing ASP.NET development

xiaoxiao2021-03-05  22

MessageBox control in developing ASP.NET development

I believe that the use of the programmer using the ASP.NET to develop Web will miss the information prompts for using Messagebox.show (""). Unfortunately, such functional functions are not supported in ASPX, but most is to use Alert ("") in the script to achieve the purpose. If you want to control the display of the client information in the code of the server, you can't control it directly.

The following is a web custom control used to develop a web custom control in the server to control the client information prompt form, which is very easy!

Its operation is very simple, the code is very small, I believe you will be satisfied with it!

You only need to set the TEXT property of the control in the server-side code, you can see the information prompt form you need, more ideal is that the text attribute is the state of state, that is, in the next time There is no need to operate during the declapidation process.

Simply, you only need to assign a value to the Text property when you ask for display, you can assume automatic hide if you assign it.

And some point you should pay attention to the location of the control in the ASPX page, in general, it is recommended to place the page until the page, so you can jump out of the information prompt dialog in all content, otherwise it is placed in this Other pages of the contents behind the control will be temporarily hidden.

The following is the source code list of the control:

// *************************************************

Using system;

Using system.Web.ui;

Using system.Web.ui.webcontrols;

Using system.componentmodel;

Namespace BasicWebControl.MessageBox

{

///

/// Alertbox's summary description.

///

[DefaultProperty ("Text"), ToolboxData ("<{0}: alertbox runat = server> ")]

Public Class Alertbox: System.Web.ui.Control

{

PRIVATE STRING TEXT = STRING.EMPTY

///

/// Displayed, pay attention to not include single, double quotes

///

[Bindable (TRUE), Category ("Appearance"), DefaultValue ("")]

Public String Text

{

get

{

Return TEXT;

}

set

{

TEXT = VALUE;

}

}

///

///

///

Public alertbox ()

{

}

///

/// Rendeze this control to the specified output parameter.

///

/// HTML writer to be written

Protected Override Void Render (HTMLTextWriter Output)

{

IF (Text! = String.empty)

{

Output.write ("