[Control Learning-1] confirm button message prompt button

Source: Internet
Author: User

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.