Home All Groups Group Topic Archive Search About
Author
18 Jun 2009 10:13 AM
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

Author
18 Jun 2009 10:53 AM
Mark Rae [MVP]
"Axel" <n@pe.com> wrote in message
news:ua8oz1$7JHA.1568@TK2MSFTNGP06.phx.gbl...

> 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#)?

Is this a WinForms or WebForms question...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Are all your drivers up to date? click for free checkup

Author
18 Jun 2009 10:59 AM
Axel
Mark Rae [MVP] wrote:
> "Axel" <n@pe.com> wrote in message
> news:ua8oz1$7JHA.1568@TK2MSFTNGP06.phx.gbl...
>
>> 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#)?
>
> 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
Author
18 Jun 2009 12:32 PM
Mark Rae [MVP]
Show quote Hide quote
"Axel" <n@pe.com> wrote in message
news:ukBfgPA8JHA.4100@TK2MSFTNGP06.phx.gbl...

>>> 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#)?
>>
>> Is this a WinForms or WebForms question...?
>
> 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 (?)


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.

However, if your question relates to developing a desktop C# application
(which I suspect it is), then you're in the wrong newsgroup and need to post
in microsoft.public.dotnet.languages.csharp


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Author
18 Jun 2009 3:57 PM
Axel
Mark Rae [MVP] wrote:
Show quoteHide quote
> "Axel" <n@pe.com> wrote in message
> news:ukBfgPA8JHA.4100@TK2MSFTNGP06.phx.gbl...
>
>>>> 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#)?
>>>
>>> Is this a WinForms or WebForms question...?
>>
>> 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 (?)
>
>
> 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
Author
18 Jun 2009 6:18 PM
Mark Rae [MVP]
"Axel" <n@pe.com> wrote in message
news:e5QiT2C8JHA.1564@TK2MSFTNGP06.phx.gbl...

> <asp:TextBox ID="txtPriority" runat="server"
> Enabled="false"></asp:TextBox>

<asp:TextBox ID="txtPriority" runat="server" ReadOnly="true" />


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Author
18 Jun 2009 7:49 PM
Axel
Mark Rae [MVP] wrote:
> "Axel" <n@pe.com> wrote in message
> news:e5QiT2C8JHA.1564@TK2MSFTNGP06.phx.gbl...
>
>> <asp:TextBox ID="txtPriority" runat="server"
>> Enabled="false"></asp:TextBox>
>
> <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
Author
18 Jun 2009 11:00 AM
Axel
Mark Rae [MVP] wrote:
> "Axel" <n@pe.com> wrote in message
> news:ua8oz1$7JHA.1568@TK2MSFTNGP06.phx.gbl...
>
>> 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#)?
>
> 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

Bookmark and Share