473,503 Members | 7,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I pass data back to my code behind events w/o postback?

I have an ASP.NET webform that has an HTML button (with an onClick
event that calls a javascript function) and a Web Forms button (the
code behind click event saves data back to a SQL DB).

The javascript function basically creates a variable such as:

var someStrings = "foo1.jpg,foo2.jpg,foo3.jpg,foo4.jpg"

I really need to be able to access this javascript variable from the
Click event of my Web Forms button so that I can pull the file names
out of this string and do some database work on them.

Any ideas? I've thought of putting a web forms textbox on the form
and having my javascript function place the string contents in there
which is easily accessible by my web forms button click event, however
now I have an unsightly textbox that should not be on my form.

Is there an easier way to access the contents of a javascript
(client-side) variable from the click event of my web forms button?

Thanks!
Jul 23 '05 #1
2 2013
On 13 Nov 2004 12:47:07 -0800, Mike wrote:
...I've thought of putting a web forms textbox on the form
and having my javascript function place the string contents in there
which is easily accessible by my web forms button click event, however
now I have an unsightly textbox that should not be on my form.


Include the data in a hidden form field or use CSS to hide the
textfield. The former is more reliable since it will work for
people who need to apply a user stylesheet.

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #2
I am not an ASP programmer but have had a similar need using other
technologies.

Unless I am failing to understand what you want to do you could also
have ASP create the JavaScript variable for you. You could certainly
store the strings in a form field, hidden or otherwise, but you could
also do this:

var someStrings = "<% ASP code here to output the strings %>";

The ASP code to generate the strings is executed on the server and will
be done before the browser reads in the JavaScript code your ASP code
generated.

Mike wrote:
I have an ASP.NET webform that has an HTML button (with an onClick
event that calls a javascript function) and a Web Forms button (the
code behind click event saves data back to a SQL DB).

The javascript function basically creates a variable such as:

var someStrings = "foo1.jpg,foo2.jpg,foo3.jpg,foo4.jpg"

I really need to be able to access this javascript variable from the
Click event of my Web Forms button so that I can pull the file names
out of this string and do some database work on them.

Any ideas? I've thought of putting a web forms textbox on the form
and having my javascript function place the string contents in there
which is easily accessible by my web forms button click event, however
now I have an unsightly textbox that should not be on my form.

Is there an easier way to access the contents of a javascript
(client-side) variable from the click event of my web forms button?

Thanks!

Jul 23 '05 #3

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

Similar topics

3
5656
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
3
4888
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
3
5970
by: Peter | last post by:
I have a webform on this form is a User Control and another webform in IFRAME On the User Control there is a save button. I want to click this button and somehow tell the webpage in IFRAME that...
8
6563
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
7
4430
by: Andy | last post by:
Hi, I have a complicated question that I'm hoping someone can help me out with. I have a webpage that contains a plug-in. This plug-in can communicate/pass data with the webpage that contains it...
0
3015
by: bsaran | last post by:
Hi, I have a code that sort of works. The event flow is as follows: In a user control of type "FilterControl" user selects certain values from 3 related dropdown lists. (two of them have auto...
8
1513
by: Gary | last post by:
Hello, I am currently new to .NET, as you can probably tell by my last two or three threads!!! Anyway, I am using code behind as much as possible - and am curious about the way in which...
0
1678
by: db007 | last post by:
I have a problem at the moment with a web project. I have two Panels within an UpdatePanel on an aspx page (using Masterpages). I'm using ASP.Net 2.0 with an AJAX enabled website. The two...
0
3008
by: dcollier9 | last post by:
Hi ! I need to embed a text box in a footer of a GridView's boundfield column to get data prior to a row insert. The textbox is usable and showing up in the web page source using View
0
7194
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
7070
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...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.