Question __EVENTTARGET settable on postback? Alternative approach?


New member
Jun 6, 2011
Programming Experience

I am having problems setting the __EVENTTARGET on postback. It works perfectly on my development environment (standalone) but not in the live environment (corporate intranet).

I am running XPSP1 with 3.5SP1 using VS2008. Live environment is also running same.

I have a ButtonField defined in a GridView like so...
   <asp:ButtonField DataTextField="AssociatedConsultant" HeaderText="Associated Consultant(s)" Text="" CommandName="LinkButtonSelectAssociatedConsultant_Click" />

Relevant page directives are...
   <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="MainMDT.aspx.vb" Inherits="XXX.YYYY.MDT.Web.MainMDT" MasterPageFile="~/SiteMDT.Master" %>
   <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

In the RowDataBound event of the GridView, I do the following...
   lbtnAssociatedConsultant.Attributes.Add("onclick", "__doPostBack('PostBack_ModalPopupAssociatedConsultant" _
      + "','" + dr("patient_detail_id_key").ToString() _
      + "|" + dr("PatientDetail").ToString().Replace("'", "\'") _
      + "');")
where lbtnAssociatedConsultant is a handle to a LinkButton of the ordinal cell defined in the GridView.

In my development environment, the __EVENTTARGET comes through correctly as "PostBack_ModalPopupAssociatedConsultant" but in the live environment, the __EVENTTARGET and __EVENTARGUMENTS come through as the dynamic name of the controls in the GridView.

I expect that it is not a good idea to use the "__" parameters like this.

Could anybody through some light on this and hopefully suggest a work around.

Just to note... I did previously have a Javascript function call added as an attribute to the LinkButton which passed a comma separated list of strings that I split and added into a ListBox in the ModalPopupExtender but I was having problems with this because the client was now inconsistent with the view state. There was a way around that by setting some Enable? page directives (can't remember right now) but this left my app open to cross site scripting so I decided instead to use this approach to force a postback and trap it so that I could fill the modal popup ListBox using code behind and keep viewstate consistent on the client.

I hope I have given enough info here... Any help appreciated.


Top Bottom