Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script from .net code

Status
Not open for further replies.

staleb

Programmer
Feb 7, 2005
45
NO
Hi,
not sure if this is the right forum but here Go!

I have a script I want to run from my code:
Dim script as String
script &= "<script language=""javascript"">" & vbCrLf
script &= "<!--" & vbCrLf
script &= " function VisBilde()" & vbCrLf
script &= " {" & vbCrLf
script &= " var url = ['" & pUrl & "']" & vbCrLf
script &= "window.open(url, '', 'width=600,height=600');" & vbCrLf
script &= " }" & vbCrLf
script &= "//-->" & vbCrLf
script &= "</script>" & vbCrLf
Me.Page.RegisterStartupScript("KjMerke", script)


Is this the way to run a script from my .Net code.
I want to open another page after the user has saved his entries.

Hope somone can help me

When I run this code, nothing happens.
(No error message anywhere)

What should I do?
 
Yes the code is located inside a sub:

Private Sub KjenneMerkeEndret(ByVal pUrl As String)
..
..
End Sub

I debug the program and it runs throu the sub without errors
 
That will create the function so that it exists on the client (i.e it is outputted to the HTML) but you'll still need to call the javascript function from somewhere for it to fire (e.g the onload event of the body tag).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
btn.attributes.add("onclick","javascript:VisBilde();")

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
but you'll still need to call the javascript function from somewhere for it to fire (e.g the onload event of the body tag). "

How can I call it from .net code?

Is this how?
btn.attributes.add("onclick","javascript:VisBilde();")

If so this means that the user needs to click another button.
I have my application set up like this:

The user clicks a save button.
The application runs trough a Save sub cheks every input, and if one spesial input is changed,
the sub is called.

Then the user should get a new page (popup) telling him that the data is changed,
and would he like to delete a row connected to it!

So I cant have the "VisBilde" connected to a button.

 
Like I said in my previous post you can add it to "the onload event of the body tag"


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
add it to "the onload event of the body tag"

How is this done?
 
Just make the body tag runat server, add a declaration to it and then use Attributes.Add to add it.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top