Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Client Side Programming in ASP.NET

  Asked By: Ted    Date: Dec 16    Category: Asp.net    Views: 6777
  

Where can I find examples of client side programming in ASP.NET? I
know how to do it in classic ASP, but I'm guessing that there are
more streamlined ways to accomplish things now.

For example:
I'd like to be able to click a button on the main window that opens
a new window. In the new window a user can select something, and
that item is added back to the main window as a checkbox control.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Shirley Allen     Answered On: Dec 16

What you want to do requires two steps to follow:
1. The common way to add javascript code to an event handler (like onclick) is to use the Attributes collection of your WebControl. For instance, if you have a button  all you have to do to open a new window  when you click  on it is write this in the Page_Load:

[c#]
myButton.Attributes["onclick"] = "window.open([url], [hwnd], [features]);";

Remember that this button should not fire postback so you won't be able to use a Button (<asp:Button>), just use the <input type="button"> and write a runat server attribute. This way you will be using a HtmlInputButton class not a Button class and will be able to not generate a postback.

Also, you can take a look at this server control  from Andy Smith called RemoteWindow [1] which will do this job for you but will render an HyperLink, not a button

2. In the popup you will have to use window.opener to set anything you want to the parent Asp.Net page. What I would do here is reload the parent page with a querystring value generated by the popup that will indicate the dynamic creation of the checkbox  when the page loads.

Surely, you can do it without refreshing, but it will require more hacks and cross-browser issues to create a checkbox that would be able to be read on a future postback of the page.

 
Didn't find what you were looking for? Find more on Client Side Programming in ASP.NET Or get search suggestion and latest updates.




Tagged: