Hi,
I put...
void Page_PreRender(Object Src, EventArgs E)
{
txtBxPassword.Attributes.Add("onload", "value='password';");
}
in an aspx page and it doesn't appear to do anything. Is there any reason why a code block like this wouldn't run?
Cheers,
WT.
istxtBxPassworda server control ? it might not be an object yet at prerender stage (guessing) and i don't think it would have a value attribute.
If it is a server control - couldn't you just do something like this in Page_Load() -txtBxPassword.text="Password"
HTH
Showing posts with label script. Show all posts
Showing posts with label script. Show all posts
Thursday, March 29, 2012
Server side script block doesnt run
Saturday, March 24, 2012
Server Variable in Client Script
Hi All,
I am trying to pass a variable from my VB asp.net script (from for example
Sub Page_Load in mypage.aspx.vb) to my Client side script.
I have found and looked at a very good example "Client and Server Scripting
in Web Pages" but it only shows server side scripting that is written in
HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
variable value from mypage.aspx.vp to my client side script?
Sample from "Client and Server Scripting in Web Pages"
<%@dotnet.itags.org. LANGUAGE="VBSCRIPT" %
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY
<% Dim strMyServerVar
strMyServerVar = 42 %>
.......
The following line of HTML was generated on the client to print the value of
a client variable into the page after the page was sent to the browser. The
value of the client variable has been set equal to the value of the server
variable printed above.
<BR>
<BR>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var x ;
x = <%= strMyServerVar %> ;
if (x == <%= strMyServerVar%>) {
document.write ("<STRONG>The value of the client variable is " + x +
".</STRONG>")
}
//
-->
</SCRIPTFew ways... build your clientside script dynamically from within your server
side script, passing in the values.
Also, could always put the values in a hidden text box and have the
clientside pull from that.
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
Bob,
Why would you do this?
The whole point of using a code behind page is so that the programming logic
can be separated from the display. Placing the programming logic in both
places defeats one of the best things about .NET.
Just Dim your variable in the code behind and you're done.
Move this line to the code behind page like this:
Public Class WebForm1
Inherits System.Web.UI.Page
Public strMyServerVar As String = "42"
'--Rest of page code below
And remove the variable declaration from the .aspx page altogether:
Delete This: <% Dim strMyServerVar strMyServerVar = 42 %
Your code will still work the same way. The .aspx page will have access to
the variable because it's declared as Public (you could also declare it as
Protected or Protected Friend)
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
Free code library at:
www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
Bob,
Just a quick note. My previous message shows how to do what you want, but I
shouldn't have included the "Why would you do this?" at the top of the
message.
I misunderstood part of your question.
Still, the code I provided does what you need.
Happy programming!
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
Free code library at:
www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
Thanks all
The rec from S. Justin Gengo works fine. I felt there was a simple way.
Bob T
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
I am trying to pass a variable from my VB asp.net script (from for example
Sub Page_Load in mypage.aspx.vb) to my Client side script.
I have found and looked at a very good example "Client and Server Scripting
in Web Pages" but it only shows server side scripting that is written in
HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
variable value from mypage.aspx.vp to my client side script?
Sample from "Client and Server Scripting in Web Pages"
<%@dotnet.itags.org. LANGUAGE="VBSCRIPT" %
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY
<% Dim strMyServerVar
strMyServerVar = 42 %>
.......
The following line of HTML was generated on the client to print the value of
a client variable into the page after the page was sent to the browser. The
value of the client variable has been set equal to the value of the server
variable printed above.
<BR>
<BR>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var x ;
x = <%= strMyServerVar %> ;
if (x == <%= strMyServerVar%>) {
document.write ("<STRONG>The value of the client variable is " + x +
".</STRONG>")
}
//
-->
</SCRIPTFew ways... build your clientside script dynamically from within your server
side script, passing in the values.
Also, could always put the values in a hidden text box and have the
clientside pull from that.
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
Bob,
Why would you do this?
The whole point of using a code behind page is so that the programming logic
can be separated from the display. Placing the programming logic in both
places defeats one of the best things about .NET.
Just Dim your variable in the code behind and you're done.
Move this line to the code behind page like this:
Public Class WebForm1
Inherits System.Web.UI.Page
Public strMyServerVar As String = "42"
'--Rest of page code below
And remove the variable declaration from the .aspx page altogether:
Delete This: <% Dim strMyServerVar strMyServerVar = 42 %
Your code will still work the same way. The .aspx page will have access to
the variable because it's declared as Public (you could also declare it as
Protected or Protected Friend)
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
Free code library at:
www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
Bob,
Just a quick note. My previous message shows how to do what you want, but I
shouldn't have included the "Why would you do this?" at the top of the
message.
I misunderstood part of your question.
Still, the code I provided does what you need.
Happy programming!
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
Free code library at:
www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
Thanks all
The rec from S. Justin Gengo works fine. I felt there was a simple way.
Bob T
"Bob T" <twick10@.hotmail.com> wrote in message
news:e9G7ajs1DHA.2604@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am trying to pass a variable from my VB asp.net script (from for example
> Sub Page_Load in mypage.aspx.vb) to my Client side script.
> I have found and looked at a very good example "Client and Server
Scripting
> in Web Pages" but it only shows server side scripting that is written in
> HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a
> variable value from mypage.aspx.vp to my client side script?
>
> Sample from "Client and Server Scripting in Web Pages"
> <%@. LANGUAGE="VBSCRIPT" %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar
> strMyServerVar = 42 %>
> ......
> The following line of HTML was generated on the client to print the value
of
> a client variable into the page after the page was sent to the browser.
The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!--
> var x ;
> x = <%= strMyServerVar %> ;
> if (x == <%= strMyServerVar%>) {
> document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG>")
> }
> //
> -->
> </SCRIPT>
server.execute - can i call a perl script on another server ?
How can I call a perl script from my asp.net page and get back the results ?
What problem have you had when you tried?
Jeff
Subscribe to:
Posts (Atom)