Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling JS func from code behind with parameters
Message
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00845364
Message ID:
00845370
Views:
15
This message has been marked as the solution to the initial question of the thread.
First leave the .NavigateUrl property empty.
Then add an onClick event to the hyperlink to launch your javascript function. In the code behind Page_Load event:

this.hlnkControl.Attributes.Add("onClick", "onWindow(); return false;")


>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:
>
>hlnkControl.NavigateUrl = "mypage.aspx?myparam=123&Date=01/01/2003";
>
>
>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:
>
>hlnkControl.NavigateUrl = "javascript:OpenWind()";
>
>
>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.
Michael McLain
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform