Controls Postback --- Please help urgent

Discussion in 'ASP .Net Building Controls' started by Vishwanathan Raman, May 31, 2005.

  1. I have two controls

    Control A has a text box and button
    Control B has a text box

    Both these controls are pasted on custompage.aspx. When I click on button on
    Control A I do some processing and then input this information to Control B.

    I am able to achieve this but there is some issue. custompage.aspx has some
    logic that is done after Control A does some processing which is the input to
    Control B.

    I find that I am unable to achieve this.I blv the click code in Control A
    should be processed before the custompage.aspx postback begins.

    Can anybody throw some insights.

    Vishwanathan Raman, May 31, 2005
    1. Advertisements

  2. Vishwanathan Raman

    beanweed Guest

    I am not sure I understand completely, but I think I have had a similar
    problem. I wanted a contol event to finishing processing, including calling
    other methods, before using the results to affect a different control that
    would be displayed.

    My suggestion is to (re)read the control execution lifecycle
    You might see in there where you want your processing to happen. In my case,
    I overrode the OnPreRender event to change the display characteristics of
    some controls after a click event on a different control.
    beanweed, May 31, 2005
    1. Advertisements

  3. Hi

    This is what I want to achieve

    CustomPage.aspx has two user controls

    Control A
    a)Text Box

    When you click button TextProperty is set to some value+text box content

    Control B
    a)Text Box

    This is what happens

    When you click on button of Control A, custompage.aspx get posted back. In
    the page load event if I access Control A.TextProperty I get an error since
    its not set.

    It gets set only at the end of the Load event.

    This Control A.TextProperty is input to Control B.

    Please let me know if you understand my problem.

    Vishwanathan Raman, May 31, 2005
  4. Vishwanathan Raman

    beanweed Guest

    Your A.Button_Click event is processed during the "Handle Postback Events"
    stage (after Page Load). So if you want to change a property of control B to
    some value set during that stage you will have to handle it in some later or
    concurrent event. Did you try setting B.TextBox.Text in the event handler for

    Private Sub A.Button_Click(...
    A.TextProperty = somevalue
    B.TextBox.Text = A.TextProperty
    End Sub

    If that didn't work try overiding OnPreRender, e.g.

    Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
    B.TextBox.Text = A.Text_Property
    End Sub

    If that doesn't work you may have to write some sort of RaisePostbackEvent
    handler (very messy). Good luck.
    beanweed, May 31, 2005
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.