Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Thursday, 10 February 2011

Generate client side script with custom control in ASP.NET

As you already know custom control gives the flexibility and allows to add complex features for a server control (refer to MSDN:Developing and Using a Custom Web Server Control).


Now consider you would like to display modal dialog using JQuery UI and the respective .js files are already loaded by the main website.The following snippet allows you to display a button from your custom control and generate a script block on the client side to handle the click event.

public class CustomWebControl : WebControl
{
 protected override void Render(HtmlTextWriter writer)
 {
         writer.Write(@"
          
          
              

Text to be displayed in the modal dialog.

"); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "test-dialog-modal_1", @" "); } }

This is the simple case of explaining how to achieve it.


The most overlooked advantage to owning a computer is that if they foul up, there's no law against whacking them around a little. ~Eric Porterfield.

1 comments:

Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers