473,395 Members | 2,253 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,395 software developers and data experts.

Transfer Javascript string to codebehind

Hi

I have a problem, on my page (*.aspx) i have a string written on klients
computer in javascript. How can i pass this string to the codebehind
*.cs file? From there i want to store it to a database...

//Micke
Mar 19 '06 #1
4 1297
Michael Bohman wrote:
I have a problem, on my page (*.aspx) i have a string written on
klients computer in javascript. How can i pass this string to the
codebehind *.cs file? From there i want to store it to a database...


You could create a blank hidden form field and get the javascript to
populate its value before postback, e.g:

<form id="form1" runat="server">
<asp:HiddenField ID="HiddenField1" runat="server" />
<input type="submit" name="submit" value="GO" />
<br />
<asp:Literal ID="litResult" runat="server"></asp:Literal></form>
<script language="javascript" type="text/javascript">
<!--
document.form1.HiddenField1.value='Your value';
//-->
</script>

In the code behind file:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Page.IsPostBack = True Then
litResult.Text = HiddenField1.Value
End If
End Sub
Mar 19 '06 #2
Michael,

You can use one of the register script methods, there are more in the Page
class. Have a look at this.

http://msdn.microsoft.com/library/de...blocktopic.asp

I hope this helps,

Cor
"Michael Bohman" <mi************@telia.com> schreef in bericht
news:kQ*******************@newsb.telia.net...
Hi

I have a problem, on my page (*.aspx) i have a string written on klients
computer in javascript. How can i pass this string to the codebehind *.cs
file? From there i want to store it to a database...

//Micke

Mar 20 '06 #3
Cor Ligthert [MVP] skrev:
Michael,

You can use one of the register script methods, there are more in the Page
class. Have a look at this.

http://msdn.microsoft.com/library/de...blocktopic.asp

I hope this helps,

Cor
"Michael Bohman" <mi************@telia.com> schreef in bericht
news:kQ*******************@newsb.telia.net...
Hi

I have a problem, on my page (*.aspx) i have a string written on klients
computer in javascript. How can i pass this string to the codebehind *.cs
file? From there i want to store it to a database...

//Micke


Thank's i'll have a look
Mar 20 '06 #4
Leon Mayne skrev:
Michael Bohman wrote:
I have a problem, on my page (*.aspx) i have a string written on
klients computer in javascript. How can i pass this string to the
codebehind *.cs file? From there i want to store it to a database...


You could create a blank hidden form field and get the javascript to
populate its value before postback, e.g:

<form id="form1" runat="server">
<asp:HiddenField ID="HiddenField1" runat="server" />
<input type="submit" name="submit" value="GO" />
<br />
<asp:Literal ID="litResult" runat="server"></asp:Literal></form>
<script language="javascript" type="text/javascript">
<!--
document.form1.HiddenField1.value='Your value';
//-->
</script>

In the code behind file:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Page.IsPostBack = True Then
litResult.Text = HiddenField1.Value
End If
End Sub

thank's i'll have a look
Mar 20 '06 #5

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

Similar topics

0
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
5
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
1
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
0
by: Wyatt70 | last post by:
I'm attempting to implement a javascript popup calendar in a DataGrid. The calendar will be used to insert a date into a textbox. I keep getting a "System.NullReferenceException: Object reference...
4
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I have an ASP .NET page with codebehind in a vb file. The page has a dropdown control, and a JS function which used HTTP XML Request to get the data from the database, and populate the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.