Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 11th, 2003, 02:06 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default Pop-Up window from server side control

I have a RadioButtonList in a template column of DataGrid. What I would like to do, is that when a user clicks on a certain choice, a pop up window will appear. Since these controls are on the server-side, I was wondering if this can be done. I know it can with javascript from an HTML control, but can it be done with server controls.

Thanks,
Jim
 
Old November 11th, 2003, 02:25 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Great question Jim! ;)

On the page class there is a method called "RegisterStartupScript". It accepts a keyname and the script as arguments. You don't need a keyname if you don't want. With that method you can write out JavaScript to the page from your codebehind. You need to write out everything including the open and close <script> tags. The script will get dropped onto the page and if you write out JS outside of a function call, it'll run as soon as the browser gets the page. Use the standard javascript calls to open and window ("window.open...").

Me.RegisterStartupScript(Nothing, "<script...>...</script>")

Keep in mind however that you may be subject to problems with pop-up blockers.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 11th, 2003, 03:38 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Thanks. But as you know, I have in my code OnSelectedIndexChanged="rblAnswersHandler".Which calls my event server side and does what I have to do. But how do I also make it respond and call the javascript? Ex. The radiobuttonlist contains "Yes", "No" and "N/A". I need to have another window pop up if they choose "Yes" only. Do I somehow in my rblAnswersHandler have it call the javascript? Can it respond to both server and client side events? Just not sure how to implement it. Thanks!!!!!!:)
 
Old November 11th, 2003, 04:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Well you aren't calling the javascript. In your handler you write out the javascript.

Public Sub rblAnswersHandler()
    Me.RegisterStartupScript(Nothing, "<script...>...</script>")
End Sub

This writes the JS out to the browser so when the page is redrawn that script will execute automatically.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 11th, 2003, 04:42 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Ahhh so I can check what value was clicked through VB and if it is "Yes" then write out the javascript that I need to run, passing it any parameters necessary ...
Cool.. I will try it ... :)



 
Old November 11th, 2003, 05:00 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Awesome.. It works.. just did a quick test.. but it works!!!!!:D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Pop up window from inside Web user control debjanib ASP.NET 2.0 Basics 5 October 22nd, 2008 12:37 AM
Server side on code on control property jayaraj123 ASP.NET 2.0 Professional 1 May 23rd, 2007 08:30 AM
Window refresh and window pop up in Java Script Aleksandra Javascript How-To 2 March 2nd, 2007 06:47 PM
control window media server programmatically pratik28 General .NET 0 August 7th, 2006 02:12 AM
can you get window.opener data in server side code edmicman Javascript 3 August 27th, 2005 03:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.