Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change readonly property at runtime

Posted on 2004-08-17
3
Medium Priority
?
375 Views
Last Modified: 2008-03-17
i need to be able to set the readonly property of a textbox at run time. I can see that this property is part of the html. Can you give me an example in vb.net as to how i code this. Thank you...Glee
0
Comment
Question by:GleeFinnegan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
jnhorst earned 1600 total points
ID: 11825589
In your Page_Load() event check the IsPostBack property of the Page object.  If it is false, set the ReadOnly property to true.  The following assumes a TextBox server control named txtTest is on the page.

If Page.IsPostBack = False Then
     txtTest.ReadOnly = False
End If

You should then see the readonly attribute in the <INPUT> element that is rendered as HTML when the page shows in the browser.

John
0
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 400 total points
ID: 11825938
Hi there,
if you are using an ASP TextBox (one from the WebForms tab in the ToolBox), just use..
TextBox1.ReadOnly = True/False

if you are using an HTML TextField (one from the HTML tab in the ToolBox), first right click on it and make it "Run At Server",  assign some ID to it, say Text1. Then set the readonly attribute to true/false.
        Text1.Attributes.Add("readonly", "true")

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/readonly_1.asp

-Baan
0
 

Author Comment

by:GleeFinnegan
ID: 11831295
Thank you both for your suggestions. The first one is the one that is appropriate for my situation. The second one may be useful in the future. Glee
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question