Shortcuts

passing variables from asp.net to javascript

Hi I hope somebody can help me. I'm trying to send a string variable from a ASP.NET page to a popup HTML with javascript. More specifically this is what i'm doing. the ASP.NET page is connected to a database that has a list of media files, i want a datalist
with hyperlinks that are databound to the media files. when u click on the hyperlink i want a pop up HTML page that uses java script to populate the media in an embeded media player. I hope this makes sense, any help would be appreciated and code examples
would be extra cream...

Re: passing variables from asp.net to javascript

i tried that last night along with alot of other possibilities, I do appreciate ur response and i'll give it another try with the onclick attribute, maybe I missed somthing. I was thinking about the problem at work today and there definately does not seem to
be an easy solution. I want to use a server side variable in a client side function. if there was a way to use asp.net to make a popup window that would make things so much easier, or if i could execute some server side code when i click the hyper link before
it called the href. I don't know, like I said i'll try this solution again, i may have missed something, if it doesn't work i'll post my code up here to see.

Re: passing variables from asp.net to javascript

Yeah now I remember why that didn't work last night. I wasn't too clear in the original post so I'll explain a little better. I want to pass a server side variable into a completely different pop up window, and then use that variable in a client side script.
If I used a hyperlink like u suggested, there is no way for me to grab the dynamic variable since u have to apply the attributes property in the Form_load event. The hyperlink does not have a click event, and the link button control does not have a targetURL
property... Does this clear it up???

Re: passing variables from asp.net to javascript

I've been thinking more about it and i think i'm going about this all the wrong way. I don't think java can help me in this situation because i need a dynamic variable from the sql server. Since java can't pass variables from one page to another (if this isn't
true tell me!) i don't think java can help me. Let me explain the flow of the code i want to write, as a matter of fact i'll use psuedo code... ' Private Sub LinkButton1_Click(ByVal sender As System.Object, ' ByVal e As System.EventArgs) Handles LinkButton1.Click
'Dim MediaURL as String 'variable to store the URL of the media 'file i want to play in the popup window 'MediaURL = LinkButton1.CommandArgument 'Application("MediaURL") = MediaURL 'save the variable in the session state 'Server.Transfer("ThisGroup.aspx")
'this WOULD be perfect if there was a argument 'to make the transer open in a pop up window End Sub Keep in mind the above link button resides in a datalist. The CommandAttribute of the link button is databound to a table in the sql server. Any idea how to
do this. I really would like it in a pop up window. I've thought about it and, if i have to, i'll create a popup HTML file for each and every media file on the server. It wouldn't be that hard with the companion program i'm writing for maintenance of the data
and media files, but I really don't want to...

Re: passing variables from asp.net to javascript

You can not open popup from server. Only from client script. You can pass data from page to popup in javascript. QueryString is one option, dialogArguments is another, you can also access parent window from popup through window.opener. And stiletto is absolutely
right about xp sp2.

Re: passing variables from asp.net to javascript

Hey guys, thk u so much for all of your help. Query string turned out to be the answer to my prayers. I looked at that option before but it didn't work, I don't remember why. It's working beautifully now and i can't believe how easy it's going to be. Also i'm
well aware of the pop up blocker of SP2 but since the user will be clicking a hyperlink, and i'm not opening it on my own there shouldn't be a plm. If it turns out to be an issue i'll put a disclaimer on the page warning the users. Thx again for all your help,
and ur patience is greatly appreciated...

Re: passing variables from asp.net to javascript

Well, i thought i had it all figured out. I hope u guys are still looking at this thread, because i have another question. How do i get javascript to see a variable passed through a query string. I know i can't use java script to access it directly, but is
there a round about way of doing this using asp to get the query string and then... i don't know. whatever works, if u know somthing help me out...