C# locked textboxes

A

Axel

Hi,

I know I can set my form's textboxes ReadOnly property to disable them,
but how can I "lock" them instead? THe user still needs to be able to
select the text in them so they can paste it if needed. (I think this
used to be possible in VB, how can I do it in C#)?

thanks in advance,
Axel
 
A

Axel

Mark said:
Is this a WinForms or WebForms question...?
Hi Mark,

this is a question about a standard Textbox (dragged from the Standard
Toolbox menu). Sorry, I am a C# newbie so I don't know about WinForms or
WebForms, but I hope that answers your question (?)

thanks in advance
Axel
 
A

Axel

Mark said:
Is this a WinForms or WebForms question...?
Hi Mark,

this is a question about a standard Textbox (dragged from the Standard
Toolbox menu). Sorry, I am a C# newbie so I don't know about WinForms or
WebForms, but I hope that answers your question (?)

Actually need to rephrase my original question

.... so they can copy it (to the clipboard) ...
(instead of paste)

thanks in advance
Axel
 
A

Axel

Mark said:
This is the ASP.NET newsgroup, for questions about developing web
applications using ASP.NET. If your question relates to the <asp:TextBox
/> web control or the <input type="text" /> HTML control (though I
suspect it doesn't), you're in the right newsgroup.

Hi Mark,

Yes, this is what it relates to - that's why I thought the framework
group was the correct one(?) here is my current code:

this is a part of the page (OI_testdetails.ascx) (it is actually a Web
User Control, but AFAIK that should behave the same as a page):

<div class="hbox">
<div id="OI_Details" runat="server" class="hpanel">
<table class="FormLblTxt">
<tr><td><asp:Label ID="lblPriority" runat="server"
Text="Priority:"></asp:Label></td>
<td><asp:TextBox ID="txtPriority" runat="server"
Enabled="false"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="lblStatus" runat="server"
Text="Status:"></asp:Label></td>
<td><asp:TextBox ID="txtStatus" runat="server"
Enabled="false"></asp:TextBox></td>
</tr>
</table>
</div>
</div>

What I would like is the asp:Textbox controls to be so that the users
can highlight text contained in the textbox to copy it to the clipboard,
but they can not change the text. The above code create INPUTs with the
disabled attribute:


<table style="width: 100%; min-width: 300px">
<tr>
<td class="leftlabel">
Customer:</td>
<td>
<input
name="ctl00$ContentPlaceHolder1$OI_Details1$txtCustomer" type="text"
value="GE Plastics"
id="ctl00_ContentPlaceHolder1_OI_Details1_txtCustomer"
disabled="disabled" class="stdTextbox"
style="width: auto; margin-right: auto;min-width: 200px" /></td>
</tr>

In my browser I can not select / highlight the text at all... could this
be a problem with my skin file or is this behavior by design?

thanks in advance
Axel
 
A

Axel

Mark said:
<asp:TextBox ID="txtPriority" runat="server" ReadOnly="true" />
Thanks Mark..

thats actually what I was looking for

I think I had started with that but (I thought that) couldn't find any
way to style it in CSS, so that's why I tried Enabled="false". But what
I meant is readonly - so now I only need to see what attribute it
sets.... surprise,surprise its called "readonly". I think I didn't find
that the first time around as I have similarly named textbox controls in
a collapsible expander at the top of the page an i must always have
looked at that in browser source code d'oh. :)

thanks again!!
Axel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top