C# locked textboxes

  • Thread starter Thread starter Axel
  • Start date Start date
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
 
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
 
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
 
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
 
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
 
Back
Top