Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Disabled textbox is nothing on postback :o(

Reply
Thread Tools

Disabled textbox is nothing on postback :o(

 
 
M O J O
Guest
Posts: n/a
 
      06-29-2006
I need to use Request.Form.AllKeys to get values of my textboxes, but
disabled textboxes are not shown.

Here's my code...

<%

@ Page Language="VB" %>
<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<

script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
ListBox1.Items.Clear()
If Page.IsPostBack Then
For Each s As String In Request.Form.AllKeys
ListBox1.Items.Add(New ListItem(s))
Next
End If
End Sub
</script>
<

html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtDisabled" runat="server"
Enabled="False">abcd</asp:TextBox><br />
<asp:TextBox ID="txtEnabled"
runat="server">abcd</asp:TextBox><br />
<asp:Button ID="Button1" runat="server"
Text="Button" /><br /><br />
<asp:ListBox ID="ListBox1"
runat="server"></asp:ListBox>
</div>
</form>
</body>
</html>


Click the button and watch the listbox ... the disabled control is not there.

I need to get values of disabled controls from inside a webcontrol (not user
control). I'm having problems using the FindControl method.

Any idea why the disabled controls are not showing??

Thanks!

Mojo

 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      06-29-2006
M O J O wrote:
> I need to use Request.Form.AllKeys to get values of my textboxes, but
> disabled textboxes are not shown.
>
> Here's my code...
>
> <%
>
> @ Page Language="VB" %>
> <!
>
> DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <
>
> script runat="server">
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
> Handles Me.Load
> ListBox1.Items.Clear()
> If Page.IsPostBack Then
> For Each s As String In Request.Form.AllKeys
> ListBox1.Items.Add(New ListItem(s))
> Next
> End If
> End Sub
> </script>
> <
>
> html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:TextBox ID="txtDisabled" runat="server"
> Enabled="False">abcd</asp:TextBox><br />
> <asp:TextBox ID="txtEnabled"
> runat="server">abcd</asp:TextBox><br />
> <asp:Button ID="Button1" runat="server"
> Text="Button" /><br /><br />
> <asp:ListBox ID="ListBox1"
> runat="server"></asp:ListBox>
> </div>
> </form>
> </body>
> </html>
>
>
> Click the button and watch the listbox ... the disabled control is not there.
>
> I need to get values of disabled controls from inside a webcontrol (not user
> control). I'm having problems using the FindControl method.
>
> Any idea why the disabled controls are not showing??


It's in the protocol. If you make the field readonly instead of disabled
the value will come over to the server side. I guess it was done to
prevent unneeded data transfers, bandwidth was scarce a few years back

Jesse
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      06-30-2006
That is standard HTML behavior unfortunately. You'll likely want to cache
the value somewhere else, such as in Viewstate or in a hidden textbox.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"M O J O" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need to use Request.Form.AllKeys to get values of my textboxes, but
> disabled textboxes are not shown.
>
> Here's my code...
>
> <%
>
> @ Page Language="VB" %>
> <!
>
> DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <
>
> script runat="server">
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Handles Me.Load
> ListBox1.Items.Clear()
> If Page.IsPostBack Then
> For Each s As String In Request.Form.AllKeys
> ListBox1.Items.Add(New ListItem(s))
> Next
> End If
> End Sub
> </script>
> <
>
> html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:TextBox ID="txtDisabled" runat="server"
> Enabled="False">abcd</asp:TextBox><br />
> <asp:TextBox ID="txtEnabled"
> runat="server">abcd</asp:TextBox><br />
> <asp:Button ID="Button1" runat="server"
> Text="Button" /><br /><br />
> <asp:ListBox ID="ListBox1"
> runat="server"></asp:ListBox>
> </div>
> </form>
> </body>
> </html>
>
>
> Click the button and watch the listbox ... the disabled control is not
> there.
>
> I need to get values of disabled controls from inside a webcontrol (not
> user
> control). I'm having problems using the FindControl method.
>
> Any idea why the disabled controls are not showing??
>
> Thanks!
>
> Mojo
>



 
Reply With Quote
 
Rick Strahl
Guest
Posts: n/a
 
      07-08-2006
Actually ReadOnly also doesn't return the value either.

I posted a BLOG entry about this some time ago and there were quite a few
useful comments there as well:

http://west-wind.com/weblog/posts/3939.aspx

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/weblog
http://www.west-wind.com/wwThreads/


"Jesse Houwing" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>M O J O wrote:
>> I need to use Request.Form.AllKeys to get values of my textboxes, but
>> disabled textboxes are not shown.
>>
>> Here's my code...
>>
>> <%
>>
>> @ Page Language="VB" %> <!
>>
>> DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <
>>
>> script runat="server">
>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.Load
>> ListBox1.Items.Clear()
>> If Page.IsPostBack Then
>> For Each s As String In Request.Form.AllKeys
>> ListBox1.Items.Add(New ListItem(s))
>> Next
>> End If
>> End Sub
>> </script> <
>>
>> html xmlns="http://www.w3.org/1999/xhtml" >
>> <head runat="server">
>> <title>Untitled Page</title>
>> </head>
>> <body>
>> <form id="form1" runat="server">
>> <div>
>> <asp:TextBox ID="txtDisabled" runat="server"
>> Enabled="False">abcd</asp:TextBox><br />
>> <asp:TextBox ID="txtEnabled"
>> runat="server">abcd</asp:TextBox><br />
>> <asp:Button ID="Button1" runat="server"
>> Text="Button" /><br /><br />
>> <asp:ListBox ID="ListBox1"
>> runat="server"></asp:ListBox>
>> </div>
>> </form>
>> </body>
>> </html> Click the button and watch the listbox ... the disabled control
>> is not there.
>>
>> I need to get values of disabled controls from inside a webcontrol (not
>> user control). I'm having problems using the FindControl method.
>>
>> Any idea why the disabled controls are not showing??

>
> It's in the protocol. If you make the field readonly instead of disabled
> the value will come over to the server side. I guess it was done to
> prevent unneeded data transfers, bandwidth was scarce a few years back
>
> Jesse


 
Reply With Quote
 
Jesse Houwing
Guest
Posts: n/a
 
      07-08-2006
* Rick Strahl wrote, On 9-7-2006 1:08:
> Actually ReadOnly also doesn't return the value either.
>
> I posted a BLOG entry about this some time ago and there were quite a
> few useful comments there as well:
>
> http://west-wind.com/weblog/posts/3939.aspx


That is a bug in .NET then, as the value is posted back from a HTML/HTTP
point of view, but thank you for pointing this out.

Jesse
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re module: Nothing to repeat, but no sre_constants.error: nothing torepeat ? Devin Jeanpierre Python 2 02-14-2012 01:33 PM
submit (or postback) does nothing in IIS 6.0 =?Utf-8?B?VHlsZXI=?= ASP .Net 1 03-01-2006 10:38 PM
Value and text are nothing on postback if ddl is filled client sid Chris Lane ASP .Net Web Controls 3 10-31-2005 06:11 PM
disabled dynamically added controls and postback djk ASP .Net 2 11-26-2004 08:21 AM
Session Variable Set to Nothing on Postback? Thanks ASP .Net 2 02-08-2004 09:41 PM



Advertisments