Wierd behavior with text box postback

Discussion in 'ASP .Net' started by =?Utf-8?B?TWljaGFlbCBMb3VnaHJ5?=, Jun 21, 2005.

  1. I'm working for a company in Houston developing a web application. At one
    point in the code, we have to refresh the page, but save what checkboxes have
    been selected. Since these checkboxes are created programmatically according
    to configuration files, they cannot be asp checkboxes.

    To do this, before refreshing I save which checkboxes are selected to an asp
    textbox and perform a postback. Later in the .aspx file, I have a <% %>
    block that calls a method from the codebehind to output a Javascript call.
    However, in this codebehind C# call, when I access the textbox's .Text field,
    it is always empty, regardless of the actual values put in the text box. The
    really strange part of it is that when the page refreshes, the asp textbox
    has the correct values in the input tag's value attribute.

    Is there some wierd execution order to ASP.NET that I am unaware of that
    would cause this? And, more importantly, is there a way around it? any help
    would be greatly appreciated.
    =?Utf-8?B?TWljaGFlbCBMb3VnaHJ5?=, Jun 21, 2005
    #1
    1. Advertising

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

    Shimon Sim Guest

    Do you have anything in onload event and if so Do you handle IsPostBack?
    "Michael Loughry" <> wrote in
    message news:...
    > I'm working for a company in Houston developing a web application. At one
    > point in the code, we have to refresh the page, but save what checkboxes
    > have
    > been selected. Since these checkboxes are created programmatically
    > according
    > to configuration files, they cannot be asp checkboxes.
    >
    > To do this, before refreshing I save which checkboxes are selected to an
    > asp
    > textbox and perform a postback. Later in the .aspx file, I have a <% %>
    > block that calls a method from the codebehind to output a Javascript call.
    > However, in this codebehind C# call, when I access the textbox's .Text
    > field,
    > it is always empty, regardless of the actual values put in the text box.
    > The
    > really strange part of it is that when the page refreshes, the asp textbox
    > has the correct values in the input tag's value attribute.
    >
    > Is there some wierd execution order to ASP.NET that I am unaware of that
    > would cause this? And, more importantly, is there a way around it? any
    > help
    > would be greatly appreciated.
    Shimon Sim, Jun 21, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?TWljaGFlbCBMb3VnaHJ5?=

    Bruce Barker Guest

    <% %> code blocks run during the page init process. this is before postback
    data is loaded into controls. your code behind can fetch the value from the
    form variable collection.

    note: databinding works by putting the binding expression in the value, then
    replacing the expression with the value when databound.

    -- bruce (sqlwork.com)



    "Michael Loughry" <> wrote in
    message news:...
    > I'm working for a company in Houston developing a web application. At one
    > point in the code, we have to refresh the page, but save what checkboxes
    > have
    > been selected. Since these checkboxes are created programmatically
    > according
    > to configuration files, they cannot be asp checkboxes.
    >
    > To do this, before refreshing I save which checkboxes are selected to an
    > asp
    > textbox and perform a postback. Later in the .aspx file, I have a <% %>
    > block that calls a method from the codebehind to output a Javascript call.
    > However, in this codebehind C# call, when I access the textbox's .Text
    > field,
    > it is always empty, regardless of the actual values put in the text box.
    > The
    > really strange part of it is that when the page refreshes, the asp textbox
    > has the correct values in the input tag's value attribute.
    >
    > Is there some wierd execution order to ASP.NET that I am unaware of that
    > would cause this? And, more importantly, is there a way around it? any
    > help
    > would be greatly appreciated.
    Bruce Barker, Jun 22, 2005
    #3
  4. I'm not enitrely sure I understand what you mean. What form variable
    collection? And how exactly does data binding work?

    "Bruce Barker" wrote:

    > <% %> code blocks run during the page init process. this is before postback
    > data is loaded into controls. your code behind can fetch the value from the
    > form variable collection.
    >
    > note: databinding works by putting the binding expression in the value, then
    > replacing the expression with the value when databound.
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    > "Michael Loughry" <> wrote in
    > message news:...
    > > I'm working for a company in Houston developing a web application. At one
    > > point in the code, we have to refresh the page, but save what checkboxes
    > > have
    > > been selected. Since these checkboxes are created programmatically
    > > according
    > > to configuration files, they cannot be asp checkboxes.
    > >
    > > To do this, before refreshing I save which checkboxes are selected to an
    > > asp
    > > textbox and perform a postback. Later in the .aspx file, I have a <% %>
    > > block that calls a method from the codebehind to output a Javascript call.
    > > However, in this codebehind C# call, when I access the textbox's .Text
    > > field,
    > > it is always empty, regardless of the actual values put in the text box.
    > > The
    > > really strange part of it is that when the page refreshes, the asp textbox
    > > has the correct values in the input tag's value attribute.
    > >
    > > Is there some wierd execution order to ASP.NET that I am unaware of that
    > > would cause this? And, more importantly, is there a way around it? any
    > > help
    > > would be greatly appreciated.

    >
    >
    >
    =?Utf-8?B?TWljaGFlbCBMb3VnaHJ5?=, Jun 22, 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. paul reed

    Wierd Behavior of __doPostBack

    paul reed, Jul 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    548
    Bassel Tabbara [MSFT]
    Jul 8, 2003
  2. Steve

    Wierd datalist behavior

    Steve, Jul 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    322
    Steve
    Jul 8, 2003
  3. Gnarlodious
    Replies:
    4
    Views:
    17,553
    elizas
    May 5, 2010
  4. Qun Cao

    wierd threading behavior

    Qun Cao, Oct 15, 2005, in forum: Python
    Replies:
    6
    Views:
    286
    dcrespo
    Oct 18, 2005
  5. subaruwrx88011

    Wierd Map Behavior

    subaruwrx88011, Feb 20, 2006, in forum: C++
    Replies:
    5
    Views:
    367
    subaruwrx88011
    Feb 20, 2006
Loading...

Share This Page