Our ASP page includes a hidden field that stores a selected value for deletion from a database:
<asp:HiddenField ID="TargetField" runat="server" />
Within the same page, there is a popup with a delete button. Clicking this button "sets" the field and triggers server code:
<asp:Button ID="ButtonDelete" runat="server" Text="Delete" CommandName="Delete" CommandArgument='<%# Eval("DataBoundGuidField") %>' />
The server code programmatically sets the "OnClick" JavaScript in the appropriate DataBound handler, like so:
var btnSelectValue = CType(e.Row.FindControl("SelectValue"), Button)
btnSelectValue .Attributes.Add("onclick", String.Format("document.getElementById('{0}').value=document.getElementById('{1}').value; return true;", SourceField.ClientID, TargetField.ClientID))
The server code also has a handler for the click event:
protected void DeleteButtonClickHandler(object sender, EventArgs e)
{
// This line seems to be causing an issue - it always returns string.Empty in IE9 but works in Chrome
var selectedValue = TargetField.Value
}
I am trying to figure out why this mechanism of copying the value to an element and reading it on the server works in Chrome but not in IE9... and if there is a possible fix. Thank you in advance.
UPDATE
Upon request, here are the first few lines of rendered HTML (no METAs included):
<!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><link href="..</head>
Here are the initial lines of the ASPX markup:
<%@ Page Language="C#" MasterPageFile="~/Masters/Menu.master" AutoEventWireup="false" CodeFile="Default.aspx.cs" Inherits="EditScreen_Default" title="Edit Screen" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
And these are the values rendered as SourceField.CliendId / TargetField.ClientId in the HTML code respectively:
<input type="hidden" name="ctl00$ContentPlaceHolderMain$GridViewRows$ctl03$SourceField" id="ctl00_ContentPlaceHolderMain_GridViewRows_ctl03_SourceField" value="8aaa7a7a-7082-4a1b-8dab-c25b0d98c263" />
<input type="hidden" name="ctl00$ContentPlaceHolderMain$TargetField" id="ctl00_ContentPlaceHolderMain_TargetField" />