|
-
Mar 2nd, 2006, 06:43 AM
#1
Thread Starter
Lively Member
How come RegisterStartupScript doesn't work if there is codes on the next line?
I have implement a javascript codes into the sub procedure and execute it by using the RegisterStartupScript. One thing I find out about using the RegisterStartupScript, is that if there is codes after it, it doesn't work. But if I erased all of the codes after it, it will work. How come?
Dim strCreateFile As String
strCreateFile = "<script language='javascript'>"
strCreateFile += "{ var fso = new ActiveXObject('Scripting.FileSystemObject');"
strCreateFile += "var textFile = fso.CreateTextFile('C:\\CUTTER.vts');"
strCreateFile += "var text = 'Version = " + txtVersion.Text + "';"
strCreateFile += "textFile.WriteLine(text);"
strCreateFile += "textFile.Close();}"
strCreateFile += "</script>"
RegisterStartupScript("Startup", strCreateFile)
-
Mar 2nd, 2006, 09:19 AM
#2
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
VB Code:
Dim strCreateFile As String
strCreateFile = "<script language='javascript'>"
strCreateFile += "function myfxn(){ var fso = new ActiveXObject('Scripting.FileSystemObject');"
strCreateFile += "var textFile = fso.CreateTextFile('C:\\CUTTER.vts');"
strCreateFile += "var text = 'Version = " + txtVersion.Text + "';"
strCreateFile += "textFile.WriteLine(text);"
strCreateFile += "textFile.Close();}"
strCreateFile += "</script>"
Page.RegisterClientScriptBlock("myfxn",strCreateFile)
Page.RegisterStartupScript("myfxncall","<script language=javascript>myfxn();</script>")
-
Mar 2nd, 2006, 10:12 AM
#3
Thread Starter
Lively Member
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
It didn't work. The code afterwards is: Response.Redirect("C:\myfile.txt")
-
Mar 2nd, 2006, 10:21 AM
#4
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
Response.Redirect stops page execution and redirects the file to c:\myfile.txt. It's not supposed to work. Nothing is.
Why are you redirecting afterwards? Any reason?
-
Mar 2nd, 2006, 10:26 AM
#5
Thread Starter
Lively Member
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
To launch that created file. Within the file, it has Username, password, port number, etc. Is there a better way than using Response.Redirect?
-
Mar 2nd, 2006, 10:28 AM
#6
Thread Starter
Lively Member
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
What is the purpose of the RegisterClientScriptBlock anyways? The codes work with just the RegisterStartupScript.
-
Mar 2nd, 2006, 10:42 AM
#7
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
Startup script is to be called when the page loads.
Client script block is to register your javascript functions. Functions, not calls to functions.
Try using javascript's document.location.href to navigate to the created file.
-
Mar 2nd, 2006, 03:47 PM
#8
Thread Starter
Lively Member
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
document.location.href works on the local computer with the ASP.NET page on the same computer as the hosting. But not on the server and accessing from a local computer.
My boss just went ahead and order a product called, Intralaunch, which use to launch file and it works but it just cost money.
Still want to know about launching a file through coding though. If it is ever possible..
-
Mar 3rd, 2006, 10:03 AM
#9
Re: How come RegisterStartupScript doesn't work if there is codes on the next line?
What happens instead?
Does the file you created actually GET created on the client's machine? Can you verify this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|