How do you access a client var value from a server control?

E

Evan Kontos

I have the need to test for the value of a client variable from a server
control in a VB Web form. How can I do this in VB. Net?

Evan Kontos | (e-mail address removed)

27 Whitehall St. | 3rd Floor | New York, NY 10004
Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
www.comtekcadd.com
 
L

Lewis Wang [MSFT]

Hi Evan,

Does the client variable in javascript?

You can put the value in a html hidden control, and set runat=server and
id=''Hide'. In the server side, define a HtmlInputHidden type variable
named Hide as a protected field of the Web Form class. Here are some
snippets demonstrating how to do this.

In *.aspx:

<form id="Form1" method="post" runat="server" onsubmit="SMIT()">
<INPUT type="hidden" id="Hide" runat="server">
<input type =submit >
</form>

<script language="javascript">
var a=1;//pass the variable "a" to server.
function SMIT()
{
window.document.Form1.Hide.value =a;
}
</script>

In the code behind:
(The VS.NET IDE will engender the following line automatically when you set
"runat=server id=Hide" for the html hidden control. )
Protected WithEvents Hide As System.Web.UI.HtmlControls.HtmlInputHidden

After the page is post back, we can get the value in on the server side
using "Hide.value".

Does this answer your question? Please let me know if you need more
information

Best regards,
Lewis

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: Evan Kontos <[email protected]>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: How do you access a client var value from a server control?
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| Date: Thu, 28 Aug 2003 17:05:54 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:132014
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I have the need to test for the value of a client variable from a server
| control in a VB Web form. How can I do this in VB. Net?
|
| Evan Kontos | (e-mail address removed)
|
| 27 Whitehall St. | 3rd Floor | New York, NY 10004
| Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
| www.comtekcadd.com
|
|
| Don't just participate in USENET...get rewarded for it!
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top