Re: JavaScript
- From: "Lau Lei Cheong" <leu_lc@xxxxxxxxxxxx>
- Date: Tue, 17 Jan 2006 16:03:11 +0800
If everything in your script is static, you may put it in a .js file (say
"myscript.js") and have a <script> tag within your <head> portion of ASPX
file.
<html>
<head>
...
<script language="javascript" type="text/javascript"
src="myscript.js">
...
</head>
<body>
...
</body>
</html>
P.S.: Next time, only post question in plain text format, not in RTF one. It
cause trouble for me that I can't copy & paste the code from VS.NET IDE to
news client. I have to type them by hand, and it'll more prone to typing
mistake.
"Peter" <pczurak@xxxxxxxxxxxxx>
???????:eUkzbzyGGHA.3944@xxxxxxxxxxxxxxxxxxxxxxx
I have the following code that executes JavaScript, is there a way I can put
the same JavaScript code in it's own file and execute the code in that file
instead of having this JavaScript code in my C# code?
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.Page.IsClientScriptBlockRegistered("LetterScript"))
{
this.Page.RegisterClientScriptBlock(
"LetterScript",
"<script language=javascript>" +
"function CreateLetter(){" +
"var word = new ActiveXObject(\"Word.Application\");" +
"word.Visible = true; " +
"var file = document.getElementById('txtTemplate').value; " +
"var objDoc = word.Documents.Add(file); " +
"objDoc.FormFields(\"FirstName\").Result =
document.getElementById('txtFirstName').value; " +
"objDoc.FormFields(\"LastName\").Result =
document.getElementById('txtLastName').value; " +
"} " +
"self.focus(); " +
"</script>");
}
this.Button1.Attributes.Add("onClick", "CreateLetter()");
}
Thanks
Peter
.
- Prev by Date: Re: Deriving from MembershipUser and ASPNET Config Tool
- Next by Date: Newbie question
- Previous by thread: RE: 2.0 on root and 1.1 in virtual
- Next by thread: RE: JavaScript
- Index(es):