Composite Controls, eventhandlers and knowing which control caused postback

Discussion in 'ASP .Net' started by Martin, May 14, 2005.

  1. Martin

    Martin Guest

    Hi,

    I have created a composite control that has a number of standard asp.net
    controls on it that can themselves cause postbacks.
    What i need to do in my composite control is to determine which consituent
    control caused a postback.

    for example a have a consituent controls with two buttons on it "button1"
    and "button2"
    I have registered my control for postbacks using
    "Page.RegisterRequiresPostBack(this);"

    I have include a dynamic handler for my buttons and registered this however
    when I click the button the code in my dynamic handler does not get raised.

    however, because I have implemented "IPostBackDataHandler " the event
    "RaisePostDataChangedEvent()" does get raised however this seems to have no
    information in it about which button was clicked all it tells me is that a
    postback occured.

    what ideally i need to do is get the dynamic button handlesr to work, can
    any body give me any advice on this or point me to a good article that shows
    how to run button handlers from within compsoite controls.
    i have included my code below for anybody's reference. -- this is my entire
    test user control.

    many thanks in advance.

    cheers

    martin.

    using System;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.ComponentModel;

    using System.Collections.Specialized;

    namespace CompositeControls

    {

    /// <summary>

    /// Summary description for Compositecontrol.

    /// </summary>

    [DefaultProperty("Text"),

    ToolboxData("<{0}:Compositecontrol runat=server></{0}:Compositecontrol>")]

    public class Compositecontrol : System.Web.UI.WebControls.WebControl,
    IPostBackDataHandler

    {

    private Panel pnl;

    private string text;


    [Bindable(true),

    Category("Appearance"),

    DefaultValue("")]

    public string txtFirstName

    {

    get

    {

    return text;

    }

    set

    {

    text = value;

    }

    }

    protected override void OnInit(EventArgs e)

    {

    base.OnInit(e);

    if (Page != null)

    Page.RegisterRequiresPostBack(this);

    }



    protected override void CreateChildControls()

    {

    System.Web.HttpContext.Current.Trace.Write("CreateChildControls()");

    pnl = new Panel();

    TextBox txtbox = new TextBox();

    txtbox.ID = UniqueID;

    txtbox.Text = txtFirstName;

    pnl.Controls.Add(txtbox);

    Button btn;

    btn = new Button();

    btn.Text = "Submit control 1";

    btn.Click += new EventHandler(btn_Click);

    btn.ID = UniqueID +1;

    pnl.Controls.Add(btn);

    btn = new Button();

    btn.Text = "Submit control 2";

    btn.Click += new EventHandler(btn_Click);

    btn.ID = UniqueID +2;

    pnl.Controls.Add(btn);

    base.CreateChildControls();

    }

    private void btn_Click(object sender, EventArgs e)

    {

    System.Web.HttpContext.Current.Response.Write("******GOT THE Button Click
    from btn_Click !!!!*****");

    System.Web.HttpContext.Current.Trace.Write("******GOT THE Button Click from
    btn_Click !!!!*****");

    }

    /// <summary>

    /// Render this control to the output parameter specified.

    /// </summary>

    /// <param name="output"> The HTML writer to write out to </param>

    protected override void Render(HtmlTextWriter output)

    {

    System.Web.HttpContext.Current.Trace.Write("Render()");

    pnl.RenderControl(output);

    }

    public virtual bool LoadPostData(string postDataKey,

    NameValueCollection postCollection)

    {

    foreach (string s in postCollection)

    {

    System.Web.HttpContext.Current.Response.Write(s + " : value " +
    postCollection.Get(s) + "<br>");

    }

    String presentValue = txtFirstName;

    String postedValue = postCollection[postDataKey];

    System.Web.HttpContext.Current.Response.Write(postDataKey.ToString());

    if (presentValue == null || !presentValue.Equals(postedValue))

    {


    txtFirstName = postedValue;

    return true;

    }

    return false;

    }



    public virtual void RaisePostDataChangedEvent()

    {

    System.Web.HttpContext.Current.Response.Write("******GOT THE Event from
    RaisePostDataChangedEvent!!!!*****<br>");

    System.Web.HttpContext.Current.Response.Write("Need to deciede which control
    event raised the postback<br>");

    Control control = null;

    string ctrlname = Page.Request.Params.Get("__EVENTTARGET");

    if (ctrlname != null && ctrlname != string.Empty)

    {

    control = Page.FindControl(ctrlname);

    }

    else

    {

    foreach (string ctl in Page.Request.Form)

    {

    Control c = Page.FindControl(ctl);

    if (c is System.Web.UI.WebControls.Button)

    {

    control = c;

    break;

    }

    }

    }

    //System.Web.HttpContext.Current.Response.Write(ctrlname.ToString());

    //OnValueChanged(EventArgs.Empty);

    }

    }

    }
     
    Martin, May 14, 2005
    #1
    1. Advertising

  2. Martin

    Teemu Keiski Guest

    Hi,

    because the control contains postbacking child controls, it would need to
    implement INamingContainer interface.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU


    "Martin" <> wrote in message
    news:...
    > Hi,
    >
    > I have created a composite control that has a number of standard asp.net
    > controls on it that can themselves cause postbacks.
    > What i need to do in my composite control is to determine which consituent
    > control caused a postback.
    >
    > for example a have a consituent controls with two buttons on it "button1"
    > and "button2"
    > I have registered my control for postbacks using
    > "Page.RegisterRequiresPostBack(this);"
    >
    > I have include a dynamic handler for my buttons and registered this
    > however
    > when I click the button the code in my dynamic handler does not get
    > raised.
    >
    > however, because I have implemented "IPostBackDataHandler " the event
    > "RaisePostDataChangedEvent()" does get raised however this seems to have
    > no
    > information in it about which button was clicked all it tells me is that a
    > postback occured.
    >
    > what ideally i need to do is get the dynamic button handlesr to work, can
    > any body give me any advice on this or point me to a good article that
    > shows
    > how to run button handlers from within compsoite controls.
    > i have included my code below for anybody's reference. -- this is my
    > entire
    > test user control.
    >
    > many thanks in advance.
    >
    > cheers
    >
    > martin.
    >
    > using System;
    >
    > using System.Web.UI;
    >
    > using System.Web.UI.WebControls;
    >
    > using System.ComponentModel;
    >
    > using System.Collections.Specialized;
    >
    > namespace CompositeControls
    >
    > {
    >
    > /// <summary>
    >
    > /// Summary description for Compositecontrol.
    >
    > /// </summary>
    >
    > [DefaultProperty("Text"),
    >
    > ToolboxData("<{0}:Compositecontrol runat=server></{0}:Compositecontrol>")]
    >
    > public class Compositecontrol : System.Web.UI.WebControls.WebControl,
    > IPostBackDataHandler
    >
    > {
    >
    > private Panel pnl;
    >
    > private string text;
    >
    >
    > [Bindable(true),
    >
    > Category("Appearance"),
    >
    > DefaultValue("")]
    >
    > public string txtFirstName
    >
    > {
    >
    > get
    >
    > {
    >
    > return text;
    >
    > }
    >
    > set
    >
    > {
    >
    > text = value;
    >
    > }
    >
    > }
    >
    > protected override void OnInit(EventArgs e)
    >
    > {
    >
    > base.OnInit(e);
    >
    > if (Page != null)
    >
    > Page.RegisterRequiresPostBack(this);
    >
    > }
    >
    >
    >
    > protected override void CreateChildControls()
    >
    > {
    >
    > System.Web.HttpContext.Current.Trace.Write("CreateChildControls()");
    >
    > pnl = new Panel();
    >
    > TextBox txtbox = new TextBox();
    >
    > txtbox.ID = UniqueID;
    >
    > txtbox.Text = txtFirstName;
    >
    > pnl.Controls.Add(txtbox);
    >
    > Button btn;
    >
    > btn = new Button();
    >
    > btn.Text = "Submit control 1";
    >
    > btn.Click += new EventHandler(btn_Click);
    >
    > btn.ID = UniqueID +1;
    >
    > pnl.Controls.Add(btn);
    >
    > btn = new Button();
    >
    > btn.Text = "Submit control 2";
    >
    > btn.Click += new EventHandler(btn_Click);
    >
    > btn.ID = UniqueID +2;
    >
    > pnl.Controls.Add(btn);
    >
    > base.CreateChildControls();
    >
    > }
    >
    > private void btn_Click(object sender, EventArgs e)
    >
    > {
    >
    > System.Web.HttpContext.Current.Response.Write("******GOT THE Button Click
    > from btn_Click !!!!*****");
    >
    > System.Web.HttpContext.Current.Trace.Write("******GOT THE Button Click
    > from
    > btn_Click !!!!*****");
    >
    > }
    >
    > /// <summary>
    >
    > /// Render this control to the output parameter specified.
    >
    > /// </summary>
    >
    > /// <param name="output"> The HTML writer to write out to </param>
    >
    > protected override void Render(HtmlTextWriter output)
    >
    > {
    >
    > System.Web.HttpContext.Current.Trace.Write("Render()");
    >
    > pnl.RenderControl(output);
    >
    > }
    >
    > public virtual bool LoadPostData(string postDataKey,
    >
    > NameValueCollection postCollection)
    >
    > {
    >
    > foreach (string s in postCollection)
    >
    > {
    >
    > System.Web.HttpContext.Current.Response.Write(s + " : value " +
    > postCollection.Get(s) + "<br>");
    >
    > }
    >
    > String presentValue = txtFirstName;
    >
    > String postedValue = postCollection[postDataKey];
    >
    > System.Web.HttpContext.Current.Response.Write(postDataKey.ToString());
    >
    > if (presentValue == null || !presentValue.Equals(postedValue))
    >
    > {
    >
    >
    > txtFirstName = postedValue;
    >
    > return true;
    >
    > }
    >
    > return false;
    >
    > }
    >
    >
    >
    > public virtual void RaisePostDataChangedEvent()
    >
    > {
    >
    > System.Web.HttpContext.Current.Response.Write("******GOT THE Event from
    > RaisePostDataChangedEvent!!!!*****<br>");
    >
    > System.Web.HttpContext.Current.Response.Write("Need to deciede which
    > control
    > event raised the postback<br>");
    >
    > Control control = null;
    >
    > string ctrlname = Page.Request.Params.Get("__EVENTTARGET");
    >
    > if (ctrlname != null && ctrlname != string.Empty)
    >
    > {
    >
    > control = Page.FindControl(ctrlname);
    >
    > }
    >
    > else
    >
    > {
    >
    > foreach (string ctl in Page.Request.Form)
    >
    > {
    >
    > Control c = Page.FindControl(ctl);
    >
    > if (c is System.Web.UI.WebControls.Button)
    >
    > {
    >
    > control = c;
    >
    > break;
    >
    > }
    >
    > }
    >
    > }
    >
    > //System.Web.HttpContext.Current.Response.Write(ctrlname.ToString());
    >
    > //OnValueChanged(EventArgs.Empty);
    >
    > }
    >
    > }
    >
    > }
    >
    >
    >
    >
    >
     
    Teemu Keiski, May 14, 2005
    #2
    1. Advertising

  3. Martin

    Martin Guest

    Hi Teemu,

    thanks for the reply,
    I just done a quick search on INamingContainer and the document i found
    said "This is a marker interface only."
    I am not quite sure what this means.

    can you offer any further advice or pointers in the right direction.

    cheers

    martin.

    "Teemu Keiski" <> wrote in message
    news:e%...
    > Hi,
    >
    > because the control contains postbacking child controls, it would need to
    > implement INamingContainer interface.
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    >
    >
    > "Martin" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I have created a composite control that has a number of standard asp.net
    > > controls on it that can themselves cause postbacks.
    > > What i need to do in my composite control is to determine which

    consituent
    > > control caused a postback.
    > >
    > > for example a have a consituent controls with two buttons on it

    "button1"
    > > and "button2"
    > > I have registered my control for postbacks using
    > > "Page.RegisterRequiresPostBack(this);"
    > >
    > > I have include a dynamic handler for my buttons and registered this
    > > however
    > > when I click the button the code in my dynamic handler does not get
    > > raised.
    > >
    > > however, because I have implemented "IPostBackDataHandler " the event
    > > "RaisePostDataChangedEvent()" does get raised however this seems to have
    > > no
    > > information in it about which button was clicked all it tells me is that

    a
    > > postback occured.
    > >
    > > what ideally i need to do is get the dynamic button handlesr to work,

    can
    > > any body give me any advice on this or point me to a good article that
    > > shows
    > > how to run button handlers from within compsoite controls.
    > > i have included my code below for anybody's reference. -- this is my
    > > entire
    > > test user control.
    > >
    > > many thanks in advance.
    > >
    > > cheers
    > >
    > > martin.
    > >
    > > using System;
    > >
    > > using System.Web.UI;
    > >
    > > using System.Web.UI.WebControls;
    > >
    > > using System.ComponentModel;
    > >
    > > using System.Collections.Specialized;
    > >
    > > namespace CompositeControls
    > >
    > > {
    > >
    > > /// <summary>
    > >
    > > /// Summary description for Compositecontrol.
    > >
    > > /// </summary>
    > >
    > > [DefaultProperty("Text"),
    > >
    > > ToolboxData("<{0}:Compositecontrol

    runat=server></{0}:Compositecontrol>")]
    > >
    > > public class Compositecontrol : System.Web.UI.WebControls.WebControl,
    > > IPostBackDataHandler
    > >
    > > {
    > >
    > > private Panel pnl;
    > >
    > > private string text;
    > >
    > >
    > > [Bindable(true),
    > >
    > > Category("Appearance"),
    > >
    > > DefaultValue("")]
    > >
    > > public string txtFirstName
    > >
    > > {
    > >
    > > get
    > >
    > > {
    > >
    > > return text;
    > >
    > > }
    > >
    > > set
    > >
    > > {
    > >
    > > text = value;
    > >
    > > }
    > >
    > > }
    > >
    > > protected override void OnInit(EventArgs e)
    > >
    > > {
    > >
    > > base.OnInit(e);
    > >
    > > if (Page != null)
    > >
    > > Page.RegisterRequiresPostBack(this);
    > >
    > > }
    > >
    > >
    > >
    > > protected override void CreateChildControls()
    > >
    > > {
    > >
    > > System.Web.HttpContext.Current.Trace.Write("CreateChildControls()");
    > >
    > > pnl = new Panel();
    > >
    > > TextBox txtbox = new TextBox();
    > >
    > > txtbox.ID = UniqueID;
    > >
    > > txtbox.Text = txtFirstName;
    > >
    > > pnl.Controls.Add(txtbox);
    > >
    > > Button btn;
    > >
    > > btn = new Button();
    > >
    > > btn.Text = "Submit control 1";
    > >
    > > btn.Click += new EventHandler(btn_Click);
    > >
    > > btn.ID = UniqueID +1;
    > >
    > > pnl.Controls.Add(btn);
    > >
    > > btn = new Button();
    > >
    > > btn.Text = "Submit control 2";
    > >
    > > btn.Click += new EventHandler(btn_Click);
    > >
    > > btn.ID = UniqueID +2;
    > >
    > > pnl.Controls.Add(btn);
    > >
    > > base.CreateChildControls();
    > >
    > > }
    > >
    > > private void btn_Click(object sender, EventArgs e)
    > >
    > > {
    > >
    > > System.Web.HttpContext.Current.Response.Write("******GOT THE Button

    Click
    > > from btn_Click !!!!*****");
    > >
    > > System.Web.HttpContext.Current.Trace.Write("******GOT THE Button Click
    > > from
    > > btn_Click !!!!*****");
    > >
    > > }
    > >
    > > /// <summary>
    > >
    > > /// Render this control to the output parameter specified.
    > >
    > > /// </summary>
    > >
    > > /// <param name="output"> The HTML writer to write out to </param>
    > >
    > > protected override void Render(HtmlTextWriter output)
    > >
    > > {
    > >
    > > System.Web.HttpContext.Current.Trace.Write("Render()");
    > >
    > > pnl.RenderControl(output);
    > >
    > > }
    > >
    > > public virtual bool LoadPostData(string postDataKey,
    > >
    > > NameValueCollection postCollection)
    > >
    > > {
    > >
    > > foreach (string s in postCollection)
    > >
    > > {
    > >
    > > System.Web.HttpContext.Current.Response.Write(s + " : value " +
    > > postCollection.Get(s) + "<br>");
    > >
    > > }
    > >
    > > String presentValue = txtFirstName;
    > >
    > > String postedValue = postCollection[postDataKey];
    > >
    > > System.Web.HttpContext.Current.Response.Write(postDataKey.ToString());
    > >
    > > if (presentValue == null || !presentValue.Equals(postedValue))
    > >
    > > {
    > >
    > >
    > > txtFirstName = postedValue;
    > >
    > > return true;
    > >
    > > }
    > >
    > > return false;
    > >
    > > }
    > >
    > >
    > >
    > > public virtual void RaisePostDataChangedEvent()
    > >
    > > {
    > >
    > > System.Web.HttpContext.Current.Response.Write("******GOT THE Event from
    > > RaisePostDataChangedEvent!!!!*****<br>");
    > >
    > > System.Web.HttpContext.Current.Response.Write("Need to deciede which
    > > control
    > > event raised the postback<br>");
    > >
    > > Control control = null;
    > >
    > > string ctrlname = Page.Request.Params.Get("__EVENTTARGET");
    > >
    > > if (ctrlname != null && ctrlname != string.Empty)
    > >
    > > {
    > >
    > > control = Page.FindControl(ctrlname);
    > >
    > > }
    > >
    > > else
    > >
    > > {
    > >
    > > foreach (string ctl in Page.Request.Form)
    > >
    > > {
    > >
    > > Control c = Page.FindControl(ctl);
    > >
    > > if (c is System.Web.UI.WebControls.Button)
    > >
    > > {
    > >
    > > control = c;
    > >
    > > break;
    > >
    > > }
    > >
    > > }
    > >
    > > }
    > >
    > > //System.Web.HttpContext.Current.Response.Write(ctrlname.ToString());
    > >
    > > //OnValueChanged(EventArgs.Empty);
    > >
    > > }
    > >
    > > }
    > >
    > > }
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Martin, May 14, 2005
    #3
  4. Martin

    Teemu Keiski Guest

    It means that you don't implement any methods when implementing it
    (interface doesn't include any methods, it just "marks" the type). Just add
    the declaration.

    public class Compositecontrol : System.Web.UI.WebControls.WebControl,
    IPostBackDataHandler, INamingContainer

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU



    "Martin" <> wrote in message
    news:O$...
    > Hi Teemu,
    >
    > thanks for the reply,
    > I just done a quick search on INamingContainer and the document i found
    > said "This is a marker interface only."
    > I am not quite sure what this means.
    >
    > can you offer any further advice or pointers in the right direction.
    >
    > cheers
    >
    > martin.
    >
    > "Teemu Keiski" <> wrote in message
    > news:e%...
    >> Hi,
    >>
    >> because the control contains postbacking child controls, it would need to
    >> implement INamingContainer interface.
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >>
    >>
    >> "Martin" <> wrote in message
    >> news:...
    >> > Hi,
    >> >
    >> > I have created a composite control that has a number of standard
    >> > asp.net
    >> > controls on it that can themselves cause postbacks.
    >> > What i need to do in my composite control is to determine which

    > consituent
    >> > control caused a postback.
    >> >
    >> > for example a have a consituent controls with two buttons on it

    > "button1"
    >> > and "button2"
    >> > I have registered my control for postbacks using
    >> > "Page.RegisterRequiresPostBack(this);"
    >> >
    >> > I have include a dynamic handler for my buttons and registered this
    >> > however
    >> > when I click the button the code in my dynamic handler does not get
    >> > raised.
    >> >
    >> > however, because I have implemented "IPostBackDataHandler " the event
    >> > "RaisePostDataChangedEvent()" does get raised however this seems to
    >> > have
    >> > no
    >> > information in it about which button was clicked all it tells me is
    >> > that

    > a
    >> > postback occured.
    >> >
    >> > what ideally i need to do is get the dynamic button handlesr to work,

    > can
    >> > any body give me any advice on this or point me to a good article that
    >> > shows
    >> > how to run button handlers from within compsoite controls.
    >> > i have included my code below for anybody's reference. -- this is my
    >> > entire
    >> > test user control.
    >> >
    >> > many thanks in advance.
    >> >
    >> > cheers
    >> >
    >> > martin.
    >> >
    >> > using System;
    >> >
    >> > using System.Web.UI;
    >> >
    >> > using System.Web.UI.WebControls;
    >> >
    >> > using System.ComponentModel;
    >> >
    >> > using System.Collections.Specialized;
    >> >
    >> > namespace CompositeControls
    >> >
    >> > {
    >> >
    >> > /// <summary>
    >> >
    >> > /// Summary description for Compositecontrol.
    >> >
    >> > /// </summary>
    >> >
    >> > [DefaultProperty("Text"),
    >> >
    >> > ToolboxData("<{0}:Compositecontrol

    > runat=server></{0}:Compositecontrol>")]
    >> >
    >> > public class Compositecontrol : System.Web.UI.WebControls.WebControl,
    >> > IPostBackDataHandler
    >> >
    >> > {
    >> >
    >> > private Panel pnl;
    >> >
    >> > private string text;
    >> >
    >> >
    >> > [Bindable(true),
    >> >
    >> > Category("Appearance"),
    >> >
    >> > DefaultValue("")]
    >> >
    >> > public string txtFirstName
    >> >
    >> > {
    >> >
    >> > get
    >> >
    >> > {
    >> >
    >> > return text;
    >> >
    >> > }
    >> >
    >> > set
    >> >
    >> > {
    >> >
    >> > text = value;
    >> >
    >> > }
    >> >
    >> > }
    >> >
    >> > protected override void OnInit(EventArgs e)
    >> >
    >> > {
    >> >
    >> > base.OnInit(e);
    >> >
    >> > if (Page != null)
    >> >
    >> > Page.RegisterRequiresPostBack(this);
    >> >
    >> > }
    >> >
    >> >
    >> >
    >> > protected override void CreateChildControls()
    >> >
    >> > {
    >> >
    >> > System.Web.HttpContext.Current.Trace.Write("CreateChildControls()");
    >> >
    >> > pnl = new Panel();
    >> >
    >> > TextBox txtbox = new TextBox();
    >> >
    >> > txtbox.ID = UniqueID;
    >> >
    >> > txtbox.Text = txtFirstName;
    >> >
    >> > pnl.Controls.Add(txtbox);
    >> >
    >> > Button btn;
    >> >
    >> > btn = new Button();
    >> >
    >> > btn.Text = "Submit control 1";
    >> >
    >> > btn.Click += new EventHandler(btn_Click);
    >> >
    >> > btn.ID = UniqueID +1;
    >> >
    >> > pnl.Controls.Add(btn);
    >> >
    >> > btn = new Button();
    >> >
    >> > btn.Text = "Submit control 2";
    >> >
    >> > btn.Click += new EventHandler(btn_Click);
    >> >
    >> > btn.ID = UniqueID +2;
    >> >
    >> > pnl.Controls.Add(btn);
    >> >
    >> > base.CreateChildControls();
    >> >
    >> > }
    >> >
    >> > private void btn_Click(object sender, EventArgs e)
    >> >
    >> > {
    >> >
    >> > System.Web.HttpContext.Current.Response.Write("******GOT THE Button

    > Click
    >> > from btn_Click !!!!*****");
    >> >
    >> > System.Web.HttpContext.Current.Trace.Write("******GOT THE Button Click
    >> > from
    >> > btn_Click !!!!*****");
    >> >
    >> > }
    >> >
    >> > /// <summary>
    >> >
    >> > /// Render this control to the output parameter specified.
    >> >
    >> > /// </summary>
    >> >
    >> > /// <param name="output"> The HTML writer to write out to </param>
    >> >
    >> > protected override void Render(HtmlTextWriter output)
    >> >
    >> > {
    >> >
    >> > System.Web.HttpContext.Current.Trace.Write("Render()");
    >> >
    >> > pnl.RenderControl(output);
    >> >
    >> > }
    >> >
    >> > public virtual bool LoadPostData(string postDataKey,
    >> >
    >> > NameValueCollection postCollection)
    >> >
    >> > {
    >> >
    >> > foreach (string s in postCollection)
    >> >
    >> > {
    >> >
    >> > System.Web.HttpContext.Current.Response.Write(s + " : value " +
    >> > postCollection.Get(s) + "<br>");
    >> >
    >> > }
    >> >
    >> > String presentValue = txtFirstName;
    >> >
    >> > String postedValue = postCollection[postDataKey];
    >> >
    >> > System.Web.HttpContext.Current.Response.Write(postDataKey.ToString());
    >> >
    >> > if (presentValue == null || !presentValue.Equals(postedValue))
    >> >
    >> > {
    >> >
    >> >
    >> > txtFirstName = postedValue;
    >> >
    >> > return true;
    >> >
    >> > }
    >> >
    >> > return false;
    >> >
    >> > }
    >> >
    >> >
    >> >
    >> > public virtual void RaisePostDataChangedEvent()
    >> >
    >> > {
    >> >
    >> > System.Web.HttpContext.Current.Response.Write("******GOT THE Event from
    >> > RaisePostDataChangedEvent!!!!*****<br>");
    >> >
    >> > System.Web.HttpContext.Current.Response.Write("Need to deciede which
    >> > control
    >> > event raised the postback<br>");
    >> >
    >> > Control control = null;
    >> >
    >> > string ctrlname = Page.Request.Params.Get("__EVENTTARGET");
    >> >
    >> > if (ctrlname != null && ctrlname != string.Empty)
    >> >
    >> > {
    >> >
    >> > control = Page.FindControl(ctrlname);
    >> >
    >> > }
    >> >
    >> > else
    >> >
    >> > {
    >> >
    >> > foreach (string ctl in Page.Request.Form)
    >> >
    >> > {
    >> >
    >> > Control c = Page.FindControl(ctl);
    >> >
    >> > if (c is System.Web.UI.WebControls.Button)
    >> >
    >> > {
    >> >
    >> > control = c;
    >> >
    >> > break;
    >> >
    >> > }
    >> >
    >> > }
    >> >
    >> > }
    >> >
    >> > //System.Web.HttpContext.Current.Response.Write(ctrlname.ToString());
    >> >
    >> > //OnValueChanged(EventArgs.Empty);
    >> >
    >> > }
    >> >
    >> > }
    >> >
    >> > }
    >> >
    >> >
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
     
    Teemu Keiski, May 14, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Wilson

    Which control caused cross-page postback?

    Jason Wilson, Sep 19, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    370
    Jason Wilson
    Sep 19, 2006
  2. Jason Wilson

    Which control caused cross-page postback?

    Jason Wilson, Oct 11, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    492
    Gozirra
    Oct 11, 2006
  3. PokerMan

    Knowing which control caused postback

    PokerMan, Apr 13, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    393
  4. Andrew Karcher

    Anyway to capture which control caused a postback.

    Andrew Karcher, Jul 30, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    257
    Andrew Karcher
    Jul 31, 2003
  5. Replies:
    4
    Views:
    168
    Richard Cornford
    Jan 30, 2006
Loading...

Share This Page