473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Client Side Values passed from Server

In the old form of ASP when code was executed all on one single page, I was
able to set a value into a variable and use it all over the page like this -

<% pvntDate = Date() %>
<input type="button" ID="btnTest" onclick="window.open('test.asp?mydate=<% =
pvntDate %>')">

I would like to reproduce this from the server side in the new .NET
implementation so I could pass the date value into the client side of the
page as it appear in the example above. Please help...

TIA
John
Nov 18 '05 #1
4 1463
if you are using webcontrols and button class or any thing like imagebutton
etc you should use
attributes collection and add custom values to it

in this case you want to add a clientside onclick attribute so you do
something like this

btnTest.Attributes.Add("onclick", "window.open('test.aspx?mydate" +
datetime.now + "')");

something as simple as that will add a client side attribute the the
webcontrol and will have the desired effect.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"John Cosmas" <va*****@msn.com> wrote in message
news:#a**************@tk2msftngp13.phx.gbl...
In the old form of ASP when code was executed all on one single page, I was able to set a value into a variable and use it all over the page like this -
<% pvntDate = Date() %>
<input type="button" ID="btnTest" onclick="window.open('test.asp?mydate=<% = pvntDate %>')">

I would like to reproduce this from the server side in the new .NET
implementation so I could pass the date value into the client side of the
page as it appear in the example above. Please help...

TIA
John

Nov 18 '05 #2
"John Cosmas" <va*****@msn.com> wrote in
news:#a**************@tk2msftngp13.phx.gbl:
In the old form of ASP when code was executed all on one single page,
I was able to set a value into a variable and use it all over the page
like this -

<% pvntDate = Date() %>
<input type="button" ID="btnTest"
onclick="window.open('test.asp?mydate=<% = pvntDate %>')">


Just declare a page level variable:

Private MyVariable as datetime

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #3
You have to declare the variable as PUBLIC instead of PRIVATE, otherwise the
client cannot get to the server-side code.

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"John Cosmas" <va*****@msn.com> wrote in
news:#a**************@tk2msftngp13.phx.gbl:
In the old form of ASP when code was executed all on one single page,
I was able to set a value into a variable and use it all over the page
like this -

<% pvntDate = Date() %>
<input type="button" ID="btnTest"
onclick="window.open('test.asp?mydate=<% = pvntDate %>')">


Just declare a page level variable:

Private MyVariable as datetime

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #4
"John Cosmas" <va*****@msn.com> wrote in
news:OP**************@TK2MSFTNGP15.phx.gbl:
You have to declare the variable as PUBLIC instead of PRIVATE,
otherwise the client cannot get to the server-side code.

Client side code cannot access server-side code...

The OP wanted to have a page level variable, so declaring it private would
be fine.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
I think this is the basic concept in ASP server-side development. My boss told me web application is NOT client-server application. I argued with him because browser is the client, and the server...
11
by: Tom Leylan | last post by:
(I posted this in languages.vb also... I can't figure out where things go if you use a little of a lot of things) Hi all... I'm looking for an example (or a pointer to one) related to the...
18
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure...
6
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program...
6
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
9
by: Alan Silver | last post by:
Hello, I have some simple client-side Javascript validation that was working fine until now. For some reason (don't ask me), it has stopped working and I can't figure out why. I have switched to...
3
by: Guy Debord | last post by:
Hello all, I know that this is a long shot, but I have a problem which someone reading this group *may* just be able to shed some light on. We have a new internal personnel planner/attendance...
24
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I have a hidden input field in a form which I change in some occasions on the client using javascript, but when I use "view source" I can't see these changes reflected on the page!...
1
by: John Dalberg | last post by:
What causes a server event to fire when something happens on the client? Say a user changed the gridview's page index, the server side PageIndexChanged event is fires. What makes...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.