Recently, I have just roughly finished learning <Asp.net server-side control elevation>, and will try to write some suitable controls in the future.
Today, I wrote a simple and practical message prompting button. You can run the button on the server.ProgramFirst remind the user whether to confirm the execution.
CodeIt is very simple, as follows:
Using System;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. componentmodel;
[Assembly: tagprefix ( " Langzi. webcontrols " , " Kbt " )]
Namespace Langzi. webcontrols
{
/**/ /// <Summary>
/// Kbotton
/// 1. The content of the prompt message box (Message) popped up when the client clicks this button)
///
/// </Summary>
/// <Remarks>
/// **************************************** ****************************************
/// Author: Chen dayI
/// Founding Date:
/// Modified:
/// Modification time:
/// Modification content:
/// Description:
/// Expanded the standard Button Function and added the message validation function.
/// **************************************** **************************************** *
/// </Remarks>
[Defaultproperty ( " Text " ),
Toolboxdata ( " <{0}: kbutton runat = Server> </{0}: kbutton> " )]
Public Class Kbutton: system. Web. UI. webcontrols. Button, inamingcontainer
{
Private String _ Message;
[Bindable ( True ), Category ( " Appearance " ), Defaultvalue ( "" ), Description ( " The content of the prompt message box popped up when the client clicks this button " )]
/**/ /// <Summary>
///The content of the prompt message box popped up when the client clicks this button
/// </Summary>
Public String Message
{
Get
{
Return_ Message;
}
Set
{
_ Message=Value;
}
}
/**/ /// <Summary>
///Pre-rendering. register the Javascript block with the client
/// </Summary>
/// <Param name = "E"> </param>
Protected Override Void Onprerender (eventargs E)
{
Base . Onprerender (E );
If (_ Message ! = Null )
{
_ Message. Replace ( " ' " , " \' " );
Base . Attributes. Add ( " Onclick " , " Return confirm (' " + _ Message + " ') " );
}
}
/**/ /// <Summary>
///This control is displayed to the specified output parameter.
/// </Summary>
/// <Param name = "output">HTML writer to write</Param>
Protected Override Void Render (htmltextwriter output)
{
Base. Render (output );
}
}
}
It is easy to use. If you want to prompt information, you only need to enter the prompt information in the message attribute box.
PS: I am still a dish. Don't joke about prawns ------:-)
Download: http://files.cnblogs.com/walkingboy/LangZi.WebControl.KButton.rar