473,378 Members | 1,523 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,378 software developers and data experts.

ASP.NET read value of javascript variable

My C# page contains a java script that create a variable named txt.
How can I get the value of txt when pressing a ASP.NET button?
Any idea would be appreciated.
Jul 7 '08 #1
3 2426
"Elliot" <el************@hotmail.co.ukwrote in message
news:4B**********************************@microsof t.com...
My C# page contains a java script that create a variable named txt.
How can I get the value of txt when pressing a ASP.NET button?
Any idea would be appreciated.
Easiest way is to define a hidden field and copy the value of the variable
into it on postback.

http://www.google.co.uk/search?sourc...+OnClientClick
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 7 '08 #2
Thanks for your idea, Mark.
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uU*************@TK2MSFTNGP04.phx.gbl...
"Elliot" <el************@hotmail.co.ukwrote in message
news:4B**********************************@microsof t.com...
>My C# page contains a java script that create a variable named txt.
How can I get the value of txt when pressing a ASP.NET button?
Any idea would be appreciated.

Easiest way is to define a hidden field and copy the value of the variable
into it on postback.

http://www.google.co.uk/search?sourc...+OnClientClick
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jul 7 '08 #3
On Jul 7, 2:06*pm, "Elliot" <elliot_barc...@hotmail.co.ukwrote:
My C# page contains a java script that create a variable named txt.
How can I get the value of txt when pressing a ASP.NET button?
Any idea would be appreciated.
something like this:
<input type="hidden" runat="server" id="hiddenVariableValue" />
<asp:Button ..... onClientClick="return copy_variable();" />

where
<script>
var hidden_field_id = "<%=hiddenVariableValue.ClientID%>";
function copy_variable()
{
document.getElementById(hidden_field_id ).value =
your_txt_value_here;
return true;
}
</script>

more at http://www.siccolo.com/articles.asp
Jul 8 '08 #4

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

Similar topics

21
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your...
9
by: Randell D. | last post by:
Folks, I can program fairly comfortably in PHP and can, for the most part using these skills and others that I've picked up over the years manage to read/understand most code in Javascript... so...
3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
2
by: dumbo | last post by:
Hello, who gives one more shining solution to me? My application load form "A". The form "A" by means of a push-button load form "B" that in its turn by means of a push-button load form "C". Form...
15
by: Evil Otto | last post by:
My page loads, and calls an init() function that returns content to a div on the page, as well as setting a $_SESSION variable. The content it returns includes a link that calls the same variable,...
0
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I want to display a progress bar on my web page. I have this code for progress bar in javascript in my web page. I have a button on the web page, if someone clicks that button...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
4
by: Michael Munch | last post by:
Hi I want to read the value of af text-field, create dynamic, in a form. Se below a small test-site to do that (but readning fails): I use the function Test_Read for reading the value from the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.