473,774 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make HtmlTextArea Readonly on the fly

I have a text area in which I have a client side javascript to process a "onclick". Because it is client side, I used a HtmlTextArea

<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90%" name="Summary" rows="25" runat="server" /

Depending on the circumstance the user can sometimes edit the contents and at other time they cannot. There is a readonly parameter I can use at definition time

<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90%" name="Summary" rows="25" runat="server" readonly /

but this is not "readonly=t rue" it is only "readonly" and in my VB codebehind I cannot set it

I tried using Summary.Disable d = True in the codebehind but this does not give me what I need since I have a "find" operation and when the textarea is disabled the user cannot see what is selected

How can I set this HtmlTextArea to ReadOnly on the fly (i.e., in the CodeBehind

Nov 18 '05 #1
3 7123
Hi, Michael SL,

Supposing your identifier for the textarea in the Page class is textarea1
you will be able to set the readonly property in the following way:

[C#]
//set it
textarea1.Attri butes["readonly"] = "readonly";
//reset it
textarea1.Attri butes.Remove("r eadonly");

[VB.NET]
'set it
textarea1.Attri butes("readonly ") = "readonly"
'reset it
textarea1.Attri butes.Remove("r eadonly")

Hope this helps
Martin
"Michael SL" <mi************ *****@compuware .com> wrote in message
news:D5******** *************** ***********@mic rosoft.com...
I have a text area in which I have a client side javascript to process a "onclick". Because it is client side, I used a HtmlTextArea:
<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90%" name="Summary" rows="25" runat="server" />
Depending on the circumstance the user can sometimes edit the contents and at other time they cannot. There is a readonly parameter I can use at
definition time:
<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90%" name="Summary" rows="25" runat="server" readonly />
but this is not "readonly=t rue" it is only "readonly" and in my VB codebehind I cannot set it.
I tried using Summary.Disable d = True in the codebehind but this does not give me what I need since I have a "find" operation and when the textarea is
disabled the user cannot see what is selected.
How can I set this HtmlTextArea to ReadOnly on the fly (i.e., in the CodeBehind)

Nov 18 '05 #2
Hi,

you can set the readonly attribute in codebehind by:

this.Summary.At tributes["readonly"]="readonly";

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Michael SL" <mi************ *****@compuware .com> wrote in message
news:D5******** *************** ***********@mic rosoft.com...
I have a text area in which I have a client side javascript to process a
"onclick". Because it is client side, I used a HtmlTextArea:

<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90%"
name="Summary" rows="25" runat="server" />

Depending on the circumstance the user can sometimes edit the contents and
at other time they cannot. There is a readonly parameter I can use at
definition time:

<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90%"
name="Summary" rows="25" runat="server" readonly />

but this is not "readonly=t rue" it is only "readonly" and in my VB
codebehind I cannot set it.

I tried using Summary.Disable d = True in the codebehind but this does not
give me what I need since I have a "find" operation and when the textarea is
disabled the user cannot see what is selected.

How can I set this HtmlTextArea to ReadOnly on the fly (i.e., in the
CodeBehind)
Nov 18 '05 #3
Marti

This works perfectly. Thank you very much

Michae

----- Martin Dechev wrote: ----

Hi, Michael SL

Supposing your identifier for the textarea in the Page class is textarea
you will be able to set the readonly property in the following way

[C#
//set i
textarea1.Attri butes["readonly"] = "readonly"
//reset i
textarea1.Attri butes.Remove("r eadonly")

[VB.NET
'set i
textarea1.Attri butes("readonly ") = "readonly
'reset i
textarea1.Attri butes.Remove("r eadonly"

Hope this help
Marti
"Michael SL" <mi************ *****@compuware .com> wrote in messag
news:D5******** *************** ***********@mic rosoft.com..
I have a text area in which I have a client side javascript to process "onclick". Because it is client side, I used a HtmlTextArea
<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90% name="Summary" rows="25" runat="server" />>> Depending on the circumstance the user can sometimes edit the contents an
at other time they cannot. There is a readonly parameter I can use a
definition time<TextArea id="Summary" onmouseup="SumM ouseUp()" style="WIDTH: 90% name="Summary" rows="25" runat="server" readonly />>> but this is not "readonly=t rue" it is only "readonly" and in my V
codebehind I cannot set it I tried using Summary.Disable d = True in the codebehind but this does no give me what I need since I have a "find" operation and when the textarea i
disabled the user cannot see what is selected How can I set this HtmlTextArea to ReadOnly on the fly (i.e., in th

CodeBehind

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
26327
by: Randell D. | last post by:
Folks, I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes. How can I therefore make an input type=text name=box2 a readonly while type=text name=box1 has a length of zero? This is for an intranet based application and I understand all the arguements and points that one has to consider in such that my server
5
4310
by: malcolm | last post by:
I'm trying to make a combo box custom control (Windows Forms .NET 1.1 c#) that can behave like a label programatically at run time. This is actually a strong feature request by our customers. I really don't want to have to make a UserControl that has both a label and ComboBox in it. I would rather have my control derive from a ComboBox for databinding (and other) reasons. I can get close, I've tried setting cbo.DropDownStyle =...
1
3382
by: ywchan | last post by:
I would like to make some of the rows in the datagrid read only according to certain condition. How can I make some of the rows editable while others read only in a datagrid? Thanks!
13
1507
by: Will T | last post by:
I have added an HTMLTextArea object (htaNote) to my webform.aspx and in the Page_Load codebehind I type something like: htaNote.Value = "Ouch!" Unfortunately, the intellisense does not provide the .Value for me because it does not recognize the object. I cannot reference Me.htaNote, either.
10
7259
by: GP | last post by:
Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I want to do something like this below.But I get a message Readonly is not valid property. foreach (Control ctl in pnlBenefits.Controls) { if (ctl is TextBox) ctl.ReadOnly=false; }
3
5317
by: Angela Chen | last post by:
Hi, I have a readOnly textbox. I want to be able to double click it to make it editable? How to implement it?\ Thanks a lot
1
1452
by: moondaddy | last post by:
I'm writing a winforms app in vb.net 1.1 and want to know if there's a way to dynamically change a property in a business class from readwrite to readonly and back again. The next thing I want to do is set the databound control in the UI to be readonly or disabled when the property its bound to is readonly. This is because when certain conditions are present such as a value in a another field, I want to make this field readonly. I can...
1
18968
by: dilipkp | last post by:
hi all, actually i want to make a textbox readonly... dynamically i want to change the textbox readonly and editable.. so is there any way i can specify in the style, this readonly property, and can change the style dynamically. actually i need to specify like .textboxstyle { readonly: true;
13
1870
by: birdboy272 | last post by:
I would be cool if I could develop a 3 by 3 grid that all row, column and diagonals adds up to 15, using numbers ranging from 1 to 9. When click the "check sum button" this application should Sum up all rows, columns and diagonals and put the result in the corresponding box ... Use if/else to check if all the results are 15, and congratulates the user if the answer is correct. The name of text boxes should be named appropriately. bonus...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.