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 / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Issues sending data back to server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
K Viltersten - 20 May 2008 18:32 GMT
I've used the following

<input type="hidden" ID="Carrier" runat="server" value="abc" />

Then, in JS i set the value to "oink". I've checked using a debugger that  
the value actually resides in that component. As the page gets requested  
back from the server, i also issue the following.

Button1.Text = Carrier.Value + "#";

I'd expect to see "oink#" but instead i see "abc#". Why, oh why... I've  
tested without explicit assignment of value but that only leads to "#" as  
a result.

<input type="hidden" ID="Carrier" runat="server" />

What can i be doing wrong? What more can i check?

Signature

Regards
Konrad Viltersten

Teemu Keiski - 20 May 2008 20:30 GMT
Still fighting? :-)

You probably set the Button's Text in Page_Load (since that's what I told
you to do), I failed to mention that Page_Load runs on every request. And
essentially this means that the posted value is overwritten, unless you
check in Page_Load for a postback or use directly Button's click event.

Let me put you a fully working test page here:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication2.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title></title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
       <input type="hidden" id="myHidden" runat="server" /><asp:Button
ID="btnSend"
           runat="server" Text="Send and append the value to LinkButton's
Text"
           onclick="btnSend_Click" /><br />
       <asp:LinkButton ID="linkButton" runat="server" />
       <script type="text/javascript" >
           document.getElementById('myHidden').value = (new
Date()).toString();
           alert('Value of myHidden is now ' +
document.getElementById('myHidden').value);
       </script>
   </div>
   </form>
</body>
</html>

WebForm1.aspx.cs
================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebApplication2
{
   public partial class WebForm1 : System.Web.UI.Page
   {
       protected void Page_Load(object sender, EventArgs e)
       {
       }

       protected void btnSend_Click(object sender, EventArgs e)
       {

           linkButton.Text += myHidden.Value + ",<br />";
       }

   }
}

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

I've used the following

<input type="hidden" ID="Carrier" runat="server" value="abc" />

Then, in JS i set the value to "oink". I've checked using a debugger that
the value actually resides in that component. As the page gets requested
back from the server, i also issue the following.

Button1.Text = Carrier.Value + "#";

I'd expect to see "oink#" but instead i see "abc#". Why, oh why... I've
tested without explicit assignment of value but that only leads to "#" as
a result.

<input type="hidden" ID="Carrier" runat="server" />

What can i be doing wrong? What more can i check?

Signature

Regards
Konrad Viltersten


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



©2008 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.