Getting viewstate value from readonly textbox in .NET2 (VB)

Hey guys...

I have a form that asks for several dates.  I tried using asp calendar controls to set values of the date textboxes which were readonly.  I found this annoying since each time I advanced a month and/or selected any date, it posted back and refreshed the page. So, instead, I resorted to an old
javascript function I use a lot.  The javascript creates a pop up (html) window and sets the value of the textbox when the user picks a date.  I had done this many times in ASP.NET1.  However, since upgrading to .NET2, I noticed I was getting errors and the data I was trying to pull and save into
a db from the textboxes was coming up as null.

I did a little research and found out that this was a change made in .NET2. Readonly textboxes can ONLY get their values from Viewstate or serverside code, NOT client side like javascripts.

http://forums.asp.net/thread/1134316.aspx

The only way I can get my page to work is to set readonly to false (bad idea).  The above thread suggests that I use a PreRender sub for the textbox(es).  The suggestion is from a guy as MS.  However, I added this sub to my vb code behind file and nothing happened.  The textbox is still wide
open.

Protected Sub txtStartDate_PreRender(ByVal Sender As Object, ByVal E As
System.EventArgs)
     txtStartDate.Attributes("readonly") = "readonly"
End Sub

Any suggestions or advice?  I really would like to use my javascript  calendar pop up functions to set the value of the textbox AND I'd like to  keep the txtboxes to readonly (duh).  Any advice?


TIA!
-Shane
-1
shanefowlkes
4/12/2006 1:47:30 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

2 Replies
1091 Views

Similar Articles

[PageSpeed] 23

2 things
1. should it be ( guessing )      txtStartDate.Attributes("readonly") = true
2. instead of fighting readonly textboxes - could you use a label ?

Hope That Helps
All that wander, are not lost...
What were we talkin bout
1
uncleb
4/12/2006 7:34:19 PM

1 - I'm not following.  I can't set the readonly on page_load because by then, the user could have changed the value of the textbox.  Remember...I was having the txtbox set to readonly and the value was being set by the javascript datapicker.  However, the server side / viewstate was not seeing the value of the readonly textbox.

2 - Nope.  I was hoping to avoid post backs.  To change the value of the label, I would need to postback....and if I were to do that, I would have stuck with the Calendar controls.

 

1
shanefowlkes
4/12/2006 7:54:36 PM
Reply:

Similar Artilces:

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

VB.net add textbox values together to get total
Hi Guys Im using visual studio 2005 vb.net. sql express, im a newbie and im basically trying to create a customer calculator. Ive got this code, basically i want to add the integer values of each of my text boxes together and then display them in a textbox called textbox1.  I think i have the code write to do the calculation but im stuck on how to get it to display the total in the textbox once ive hit the calculate button, ive tried several ways, the page posts back, i get no errors but nothing in textbox1 toocan you take a look and help me out please. Thanks and Kind Regards &...

How to get the value of a textbox that has been added to a template field in a gridview. VB.Net
I have a gridview that shows products, description, price. I have added a Buttonfield and a TemplateField that has a Textbox with the id QuantityTextBox.What I am trying to do is get the value of the Quantity TextBox in the RowCommand event of the gridview. I can get the price but need to get the quantity also. To get the price I used ItemPrice = Server.HtmlDecode(row.Cells(5).Text) My template field is cell 6 but the above routine does'nt work. Any help would be greatly appreciated.Dan5150www.5150creations.com Hiuse this: VB:  Protected Sub GridView1_RowCommand(ByVal ...

How to get textbox value when textbox properties is readonly or enabled false
Hi ,I have one problem, If u have idea please solve  itTo dispaly canlendercontrol iam using ajax canlender control, after selecting dateof birth into textboxIn textbox keeping textbox properites as readonly or enabled equal false,  getting that textbox value into lable,  ThanksRamesh  Just get the Textbox.Text value?Don't forget to click "Mark as Answer" on the post that helped you. If I understand you correctly, you have a textbox that is disabled/readonly. You use some code to change the value in the textbox, and you want that value to be returne...

POST GET GET GET GET... WTH?
Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

Not able to get textbox value from aspx to aspx.cs file if ReadOnly="True" for a textbox
Hi, I got a problem in .Net 3.5. Lets see my requirement... a) I have a web page with two text boxes with an image beside the first text box. When I click on the image some opertation will happen in Javascript and a popup with calender should appear and I can select a date from that. After that I will get the selected date to my aspx file with document.getElementID().value. And I will keep it into a string and then I will add 3 more days to it and will print that value in another textbox. b) When a value is selected or changed in the first textbox then TextChang...

getting value from string (VB .net)
HiJust a quickie (i hope) - i'm trying to get a value from a string but not sure what method to use.Eg Dim myString As String = "(ng) nottingham"How would i get the value between the parentheses - ng?  The values are either going to be a single or two characters if this helps?I can think of a work around using myString.IndexOf() but i'm sure there must be a specific function for this problem? thanks  Hey, You could loop through the three or four characters, use the Substring method and trim/remove the parens, or you can use regular expressions.Brian"Trust in the Lord a...

getting the value of a postback for a readonly textbox
hi guys, i have a textbox, i set as readonly or disabled. But when i do a postback, i cant seem to read the value of the textbox, either when disabled or postback is used. I tried adding this  TextBox_Groups.Enabled = true;        TextBox_Groups.ReadOnly = false; but it still doesnt work, pls help Ehi  The ReadOnly or the disabled TextBox will ingore the Newly submitted value , However , you can get the new value like this :TextBox1.Text=Request.Form(TextBox1.UniqueId)Read my blog post for more information. Regards,Anas Ghanem.Note:Please ...

How to get the textbox values into a vb-script
I'm using the club web site starterkit to develop my site and I can't get the log in function to work. The site is coded in aspx and when you push the log in button, a vb-script executes. This script is located befor the aspx body. When i write the code to get the value of the username and password textboxes, a error message accoure (UserName not declared). I've searched the Internet and all the code examples I find tells me that I've written the code correct. Why doesn't this work?This is the code I write to get the values:Protected Sub LoginButton_Click(ByVal sender As Object, ByVal e As S...

How do I get the value from this combo box in vb .net...
In asp .net I have it under control however in vb .net its not quite the same. I have a dataadapter that I pop with a ds. bind it to the combobox. Now I'm trying to get the selected value and I'm thinking I have to do a ctype but don't know what the param's are. can someone please help... Here is the code: myConnection.Open()myDataAdapter = New SqlDataAdapter(strSQL, myConnection) Dim myDataSet As DataSet = New DataSet() myDataAdapter.Fill(myDataSet, "ListingStatus") Dim myDataView As DataView = myDataSet.Tables("ListingStatus").DefaultView lstStatus.DataSource = myDataView lstStatus....

Get the column value from a DataGrid
 Hi,I have a datagrid with 6 columns. I am trying to retrieve the value of a column and pass it to a variable. I am not sure what I doing wrong here since the code I am using is not pulling any value from the column.  This is an example of what I am trying to do. Dim column_value As Stringcolumn_value = DataGrid1.Items(0).Cells.Item(4).Text                        Please correct me if I am wrong.   Thanks.    Use a GridView control instea...

Viewstate not getting reapplied unless textbox is readonly
Hi All I have this strange issue while dynamically loading a usercontrol onto a page a doing a post back from one of the controls on the control.  I'm writing an application that automates the request/approval process of access to applications with the company.  I've built an Outlook type interface using Telerik controls and I dynamically load a usercontrol into the interface dependant on what kind of application needs approval.  My problem is; when I open an existing request (so I load the control and populate it from SQL in the OnInit Page event) and then if one of the cont...

Get values set by javascript to .net enabled textbox
I have a bit of javasript that writes a value to a text box.  The text box is read only. Textbox code:<input type="text" id="txtColor1" runat="server" readonly="readonly" size="6" /> Snippet from javascript functioncolorBox = document.getElementById('<%= txtColor1.ClientID %>');colorBox.value = colorCode;  Code behind:string color1 = txtColor1.Value Whenever I attempt to get the value out of the text box after it has been changed by the javascript, it always reverts back to the old data and not the new. Anyo...

Get Scope Identity Value using ObjectDataSource and Vb.Net
Hi, I have been trying to get the scope Identity after inserting a record using an ObjectDataSource. I can't find what event, or how to get the value that the scope identity returns. Here is my Sproc. ALTER PROCEDURE dbo.[YourCompany_LanCustomer_Insert]     (     @DNNUserID int,     @FirstName nvarchar(50),     @LastName nvarchar(50),     @Address nvarchar(50),     @Address2 nvarchar(50),     @City nvarchar(50),     @State nvarchar(50),    ...

Web resources about - Getting viewstate value from readonly textbox in .NET2 (VB) - asp.net.getting-started

Viewing ASP.NET viewstate with ViewState Decoder - testingReflections.com
Tamper-Proofing A hashcode will not secure the actual data within the ViewState field, but it will greatly reduce the likelihood of someone ...

Binary-to-text encoding - Wikipedia, the free encyclopedia
The ASCII text-encoding standard uses 128 unique values (0–127) to represent the alphabetic, numeric, and punctuation characters commonly used ...

Support • FileSeek • Binary Fortress Software
FileSeek: Lightning Fast File Search!

Funny contents index page
A2Zmenu.Com Blog Tutorials Online Exam Ask Question Utility Fun @ Work Funda Contact Us About Us Loading Topic All Category Appraisal FunnyImages ...

Languages -> C# Articles, Tutorials, Examples: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Blog Archive
Blog Archive 2013 75 Essential Tools for iOS Developers Aug 15 2013 posted in iOS Speaking at Cocoa Conf PDX Jul 13 2013 posted in Speaking In ...

iTunes Sync Tested MP3 Players - Binary Fortress Software
Home • Support Binary Fortress Software The people that give you all of these great applications, and more! DisplayFusion Multi-monitor taskbar, ...

LAMP & Microsoft Stacks - SMX Sydney - David Cropley
... is a great place to start with people using IIS, it will allow you to get a better understanding of your site from an SEO perspective Use viewstates ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

The Antidote to ASP.NET Smart Navigation
One of the issues I have with ASP.NET is that it is postback crazy . Virtually nothing of significance can be done in pure browser client code ...

Resources last updated: 1/6/2016 10:10:28 AM