I need help with the following: The code behind creates hyperlink control, dynamically, in the Page_Load method. Without javascript, the .NavigateUrl property of the hyperlink control would be assigned value like this:
All would be well but I need to open page mypage.aspx in a small window without toolbar, scrollbars, and a certain size. To do this I need to call a JavaScript funtion.
I have two problems so far that I can't resolve:
1. I created a small JS function OpenWind() (in the HEAD section). And if I replace the NavigateUrl propert string above to the following:
When clicking on this hyperlink
it tries to open page 'javascript:OpenWind()'. Which is no good. 2. Even if item 1 would work, how do I pass the parameters "myparam=123&Date=01/01/2003" and aspx page name (mypage.aspx) to the javascript function? I would appreciate any help or suggestions.
Hi, U can implement this in a simple way using the server RegisterStartUpScript. The example is as follows. In the page_load event u can write this script block. string pagename = "SessionTest.aspx"; String scriptString = "<script language=JavaScript> function
DoClick() {"; scriptString += " window.open('" + pagename + "','Sample','toolbar=no,width=190,height=190,left=500,top=200,status=no,scrollbars=no,resize=no' )}"; scriptString += "<"; scriptString += "/"; scriptString += "script>"; if(!this.IsStartupScriptRegistered("Startup"))
this.RegisterStartupScript("Startup", criptString); then finally in the onload u can call this function as follows. So when the page loads the script is called and the new page opens up as required. Here the pagename variable can be assigned dynamically. This
wud give u the required solution. Any doubts u can get back. Thanks Subasree G
Dimacorp
Participant
857 Points
262 Posts
Calling JS function from code behind with parameters
Nov 01, 2003 04:28 PM|LINK
SubasreeG
Member
120 Points
24 Posts
Re: Calling JS function from code behind with parameters
Nov 04, 2003 10:12 AM|LINK
Dimacorp
Participant
857 Points
262 Posts
Re: Calling JS function from code behind with parameters
Nov 04, 2003 12:12 PM|LINK
proteus189
Member
210 Points
42 Posts
Re: Calling JS function from code behind with parameters
Nov 04, 2003 04:06 PM|LINK
javascript: window.open('','','toolbar=0,scrollbars=0,location=0,resizable=1,statusbar=0,menubar=0'); window.close()";The target of the hyperlink was also "_blank".