textbox in user control losing values during post back

Discussion in 'ASP .Net' started by =?Utf-8?B?U3JpZGhhcg==?=, Aug 23, 2006.

  1. Hi,

    I have a user control which has a textbox control and a button. I have
    created a property to get and set the text box value. In the Page_Load method
    of the Page that contains the user control, I am setting the textbox value
    that is inside the user control. When I click the button that is inside the
    user control and try to access the textbox value it is getting empty string
    instead of the value set in the Page_Load. I have tried setting
    EnableViewState explicity but still it is not holding the value. I am not
    loading the user control dynamically. Please let me know if you have any
    ideas.

    Thanks,
    Sridhar.
    =?Utf-8?B?U3JpZGhhcg==?=, Aug 23, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?U3JpZGhhcg==?=

    Lav KG Guest

    Sridhar wrote:
    > Hi,
    >
    > I have a user control which has a textbox control and a button. I have
    > created a property to get and set the text box value. In the Page_Load method
    > of the Page that contains the user control, I am setting the textbox value
    > that is inside the user control. When I click the button that is inside the
    > user control and try to access the textbox value it is getting empty string
    > instead of the value set in the Page_Load. I have tried setting
    > EnableViewState explicity but still it is not holding the value. I am not
    > loading the user control dynamically. Please let me know if you have any
    > ideas.
    >
    > Thanks,
    > Sridhar.


    Try surrounding your code by following block

    if (! IsPostBack)
    {
    // your code.
    }

    let's hope it works...:)
    Lav KG, Aug 23, 2006
    #2
    1. Advertising

  3. I am trying to access the textbox inside button_click method of the user
    control. Also when I am setting the textbox value in the Page_load method of
    the page, I have tried setting it both inside

    if not page.ispostback
    end if

    and also outside of it. None of them works.

    Thanks,
    Sridhar.

    "Lav KG" wrote:

    >
    > Sridhar wrote:
    > > Hi,
    > >
    > > I have a user control which has a textbox control and a button. I have
    > > created a property to get and set the text box value. In the Page_Load method
    > > of the Page that contains the user control, I am setting the textbox value
    > > that is inside the user control. When I click the button that is inside the
    > > user control and try to access the textbox value it is getting empty string
    > > instead of the value set in the Page_Load. I have tried setting
    > > EnableViewState explicity but still it is not holding the value. I am not
    > > loading the user control dynamically. Please let me know if you have any
    > > ideas.
    > >
    > > Thanks,
    > > Sridhar.

    >
    > Try surrounding your code by following block
    >
    > if (! IsPostBack)
    > {
    > // your code.
    > }
    >
    > let's hope it works...:)
    >
    >
    =?Utf-8?B?U3JpZGhhcg==?=, Aug 23, 2006
    #3
    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. Joby
    Replies:
    0
    Views:
    1,612
  2. Kevin Cunningham

    Label within repeater losing text on post back

    Kevin Cunningham, Jan 20, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,297
    Eliyahu Goldin
    Jan 20, 2005
  3. jason
    Replies:
    0
    Views:
    687
    jason
    Aug 31, 2005
  4. Michael Lang
    Replies:
    12
    Views:
    892
    Michael Lang
    Dec 29, 2006
  5. =?Utf-8?B?Z29yaWxsYQ==?=
    Replies:
    1
    Views:
    749
    Masudur
    May 25, 2007
Loading...

Share This Page