Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Saturday, March 24, 2012

Passing variables between Server scripts and client scripts!

Hi,

I am having difficulty in passing a variable from a server script to a client script. I am looking to take a parameter that is passed into an ASP page from another page and use this parameter in a client side script.Is it possible to do this?? A simplified version of what I want to do is:

<%
Dim Tag
Tag = Request.QueryString("ID")
%>
........

<%Script Language="VBScript">
Dim Tag2
Tag2 = <%=Tag%>
document.write(Tag2)
<Script
Any help greatly appreciated!!1. need quotes around the literal value in client script
2. need to close your Script tag

<%
Dim Tag as String = Request("ID")
%
<Script Language="VBScript">
Dim Tag2
Tag2 = "<%= Tag %>"
document.write(Tag2)
</Script>

Thank you very much!! Works a treat.

Passing Variables between script files and aspx files

Hello all,

I have a aspx.vb files which some global declarations within,


<FONT color=#0000ff size=2>Partial</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Class</FONT><FONT size=2> _Default
</FONT><FONT color=#0000ff size=2>Inherits</FONT><FONT size=2> System.Web.UI.Page</FONT><FONT size=2> <P></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> TheGood </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0
</FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> TheBad </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0
</FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> TheWarning </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0

...

How can I access these from a label within the .aspx file?


<FONT color=#0000ff size=2><</FONT><FONT color=#a31515 size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 size=2>Label</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>ID</FONT><FONT color=#0000ff size=2>="lbStatus"</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff size=2>="server"</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT color=#0000ff size=2>="TheWarning"</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>Width</FONT><FONT color=#0000ff size=2>="300px"></</FONT><FONT color=#a31515 size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 size=2>Label</FONT><FONT color=#0000ff size=2>>

Dead6re:

Hello all,

I have a aspx.vb files which some global declarations within,


PartialClass _DefaultInherits System.Web.UI.Page

Dim TheGoodAsInteger = 0
Dim TheBadAsInteger = 0
Dim TheWarningAsInteger = 0...

How can I access these from a label within the .aspx file?

<asp:LabelID="lbStatus"runat="server"Text="TheWarning"Width="300px"></asp:Label>

lbStatus.Text = TheWarning.ToString()


1PartialClass _DefaultInherits System.Web.UI.Page

2Dim TheGoodAs Integer = 0Dim TheBadAs Integer = 0Dim TheWarningAs Integer = 0

1<asp:Label ID="lbStatus" runat="server" Text="TheWarning" Width="300px"></asp:Label>

i am not getting in which scenario it would be required...

can you tell me what is your exact requirement ?