How to develop "Client script library" for ASP.net controls and how do these work?

Posted by Niranjan Kala on Programmers See other posts from Programmers or by Niranjan Kala
Published on 2011-11-25T11:33:46Z Indexed on 2011/11/25 18:03 UTC
Read the original article Hit count: 395

I have been working on .Net platform for 2 years and right now I am working on DevExpress controls for 6 months. All these control have client-side Events which are under some ClientScript nameSpace of particular control, Which specify ClientInstanceName, methods and properties accessible at client side.

For example Button1 is ClientInstanceName and Button1.Text is a property, with methods like these:

Button1.SetValue();
Button1.GetValue();

In ASP.Net Controls, buttons have the ClientClick event that fires before the Server Side Click event.

I have inspected and goggled to extend client side functionality in asp.net controls. For example: create a ClientInstanceName property for controls or CheckedChanged event for CheckBox / RadioButton control.

I have tried using these MSDN articles:

I got much information and ideas from these articles on how to implement/extend these. All are working in the client side.

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
    base.AddAttributesToRender(writer);
    string script = @"return confirm(""%%POPUP_MESSAGE%%"");";
    script = script.Replace("%%POPUP_MESSAGE%%", 
    this.PopupMessage.Replace("\"", "\\\""));
    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, script);
}

Here It is just setting up attribute to the button. but all client side interaction no control from server.

Here is that I want to know:

  1. How can I implement such functionality to create methods, properties etc. on client side.
  2. For example I am creating a PopControl as in the above code snippet same behavior as like Ajax ModalPopupExtender That have OK Button related properties. Ajax Controls can be directed to perform work from server side code e.g. Popup1.show(); How can I do this with such client enabled controls implemented controls as windows do?

I am learning creation of Ajax Controls but I do not want to use ScriptManager or depend on another control. Just some extension to standard controls.

I am expecting for ideas and implementation methods for such functionality.

© Programmers or respective owner

Related posts about best-practices

Related posts about web-development