Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / March 2006

Tip: Looking for answers? Try searching our database.

Transfer Javascript string to codebehind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Bohman - 19 Mar 2006 09:42 GMT
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
Leon Mayne - 19 Mar 2006 21:09 GMT
> 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
Michael Bohman - 20 Mar 2006 21:12 GMT
Leon Mayne skrev:
>> 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
[quoted text clipped - 22 lines]
>         End If
>     End Sub

thank's i'll have a look
Cor Ligthert [MVP] - 20 Mar 2006 08:17 GMT
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/default.asp?url=/library/en-us/cpref/html/frlr
fsystemwebuipageclassregisterclientscriptblocktopic.asp


I hope this helps,

Cor

> Hi
>
[quoted text clipped - 3 lines]
>
> //Micke
Michael Bohman - 20 Mar 2006 21:11 GMT
Cor Ligthert [MVP] skrev:
> Michael,
>
[quoted text clipped - 14 lines]
>>
>> //Micke

Thank's i'll have a look

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.