Textbox cursor in vb.net - asp.net

How can i change the mouse pointer of textbox in to hand symbol.
I am using Visual web Developer.
my intension is to have a textbox (with database value) to be placed inside the repeater's header division for allignment purpose.i made border style to none.
Thanks

just create one css and assign that css to textbox.
<style>
.txtclass{cursor:pointer;}
</style>
<asp:TextBox ID="txt" CssClass="txtclass" runat="server" />
That's it.
Hope it helps you.
EDIT :
<style>
.txtclass input[disabled="disabled"] {
// your color style
}
</style>
Try this.

Related

Another way to change the color of a checkbox's text

I'm using C# in Visual Studio 2015 with an ASP.Net front end.
I've got this line of code:
<asp:CheckBox ID="chkMedical" runat="server" Text="Medical" ForeColor="White"
Font-Size="X-Small" Visible="False" />
When I run this code, the text "Medical" is black.
Why isn't it white? Is there another way to change the text color?
Colors should be set by CSS and not C# content generation. You can technically use your code, and it should work, but something may be overriding the inline-css colors. Try adding a CssClass to your element as such:
<asp:CheckBox ID="chkMedical" CssClass="chkMedical" runat="server" Text="Medical" ForeColor="White"
Font-Size="X-Small" Visible="False" />
Then add some CSS to your page as such:
<style>.chkMedical { color: #FFF !important; } </style>
You should probably add the tags in the head of the document, or at least new the top or bottom of the .aspx page, your choice. Or you could of course add this to a CSS file that is referenced by your document.
Note that although you can use the element ID instead of a class, ASP.NET generally appends the ContentPlaceHolderID to non-static ASP controls on your page. So if we assume that your ContentPlaceHolderID is called "ContentPlaceHolder1" then the code below could also work. Since the ContentPlaceHolder may change, or someone may change your ASP Control to static (causing the element ID to change) I recommend the use of a class to avoid the potential headache (personal experience).
<style>#ContentPlaceHolder1_chkMedical { color: #FFF !important; } </style>

Making a textbox unselectable

Hi i have a textbox which i am using as a counter to show how many characters are still allowed in another textbox. I have made it read only and its background transparent so that you cant tell it is a select box. The only problem is you can still click on it or tab to it. Is there a way to do this so it appears just like normal text and people cant click on it or tab to it?
If this is an Asp.Net Web Control set it's Enabled property to false
<asp:TextBox Enabled="false" />
If it is HTML you can do this:
<input type="text" disabled />
Just replace the input element with a span element or some other non-input element. This requires a trivial change to your JavaScript; you would assign to the innerHTML property of the element rather than value. Then the content will appear as normal text, and you can style it as desired.
you need some style with css and some trick with Jquery.
CSS
.readonly{
border:none;
background:#aaa;
}​
Jquery
$(".readonly").focus(function(){
$(this).blur();
});​
now just add class="readonly" to your textbox.
<asp:TextBox cssClass="readonly" />
check demo here .

Making Text box not editable

work on C# asp.net vs 05. I have a requirment, I have to fill text box with some data on gridview , which is coming from database and make it read-only
After that user can not enter any text on gridview template field. If I set textbox Enabled=false, then i lose text color, but i want to show text color. Just textbox to not be editable. I just want users to not be able to write anything in my textbox.
Isn't there a readonly property for the text box.
If then you can use
ReadOnly="true"
for the text box.
If you can use a label then I would prefer that one.
For wrapping contents inside a label you can use
word-wrap
word-wrap: break-word
Inside the properties choose your column field and in the properties.
Under Styles section
You can give a CssClass to the column.
If you specify CssClass as 'TextStyle'
the css looks like this
.TextStyle
{
color: #a9a9a9
}
In the color attribute give either the color name like 'red' or the hexcode like '#000000' for the text.
Enabled="false"
I'd use CSS to make a label look like a textbox.
Why does everyone insist on using an asp:label for this sort of thing? Just because it renders a <span> if you don't supply an AssociatedControlId?
You should look at using an asp:Panel or possibly an asp:Literal or asp:PlaceHolder for this as they will give you greater control over the output, and cleaner markup.
Panel would be better, as this will render the contents in a <div> rather than the PlaceHolder or Literal which won't add any extra markup.
The content you are putting in here is a semantic division, and so should really be marked up as such, and by default, <div>s are treated as a block display type, rather than as inline (<span>).
Here's a quick proof of concept I just knocked up.
<head runat="server">
<style>
.readTest
{
border: none;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" Text="Do something" ReadOnly="true"
ID="txtOne" CssClass="readTest"></asp:TextBox>
</div>
</form>
</body>
</html>
Personally I would use a label, though you could write a custom control that renders a textbox or a label, depending on the state your app is in.
I'd prefer to write the text directly to the cell using a literal or String() output rather than using a control. It's a bit cleaner and will help minimize the amount of ViewState being written. Either that, or turn off ViewState for those controls being added.
Specify your CSS for the TextBox in the row created event of the GridView.

CSS Formatting for ASP Controls

I have an ASP:Label control on my page, and I would like to give it some CSS formatting. I know I could give it a CssClass name, however, it seems wrong because I want to give it a specific positioning therefore I'm looking for something more similar to the regular "id" attribute of html elements.
The ID of the label is the one used by the ASP, but in the actual html produced, I get a different ID.
Any suggestions?
Thanks.
The next version of ASP.Net will make it easier to specify an exact clientID for the control. At the moment, you have several options to work around this issue:
Inline Styles
<asp:Label runat="server" ID="MyLabel" style="..." />
CssClass
Just use a css class, as you mentioned in your quesiton. Nothing stops you from making those unique if you have to.
Write a handler to serve your style sheet
When you write your style sheet, leave placeholder in the file for client IDs. Then use an http handler to substitute in the actual rendered IDs on each request. This isn't exactly simple because the style sheet request is separate from the html page request, but it is certainly possible and so worth mentioning.
Use a container
Since a label renders as a span tag, if that span is unique within a specific naming container you can select it that way:
<div id="MyContainer"><asp:Label ID="MyLable" runat="server" /></div>
And in your style sheet:
#MyContainer span { /*...*/ }
Use a container + a class
If the container is not specific enough, you can use the class just to narrow it down within that container:
<div id="MyContainer"><asp:Label ID="MyLable" runat="server" CssClass="MyClass"/></div>
and in your style sheet:
#MyContainer span.MyClass { /*...*/ }
ASP.net essentially breaks the CSS ID selector. To get around this sometimes I will place this id in the CssClass attribute.
<style type="text/css">
input.first-name { /* style me */ }
</style>
<asp:TextBox runat="server" ID="firstName" CssClass="first-name" />
You can also add multiple class names in the CssClass attribute
<style type="text/css">
input.first-name { /* style me */ }
input.text-input { /* because ie 6 won't do input[type=text] */ }
</style>
<asp:TextBox runat="server" ID="firstName" CssClass="first-name text-input" />
I try as much as possible to not use inline style or to use the additional styling attributes provided by the controls.
Your only options are to use CssClass or inline styles. As ASP.NET auto-generates the ID's of server side controls you should never try to second guess what these will be. It can be a major pain getting Webforms to work with elegant CSS layouts.
ASP.NET 4.0 will introduce the ClientID property that should make it easier to work with ID attributes in the future.
I think you can do something like:
<asp:Label ID+"lblID" style=" [whatever style you want goes in here "] runat="server />
Remember when the control gets rendered, it gets rendered as with the ctrl.etc....
Or if you are doing positioning, can't you wrap the label in a <div>
Yeah - a major headache with web forms - the id is made up of all the contentsections, panels etc that the label (or other control) sits within.
your best bet really is to add a CssClass to the control.

RequiredFieldValidator - how to get rid of the default red font color

I can't seems to change the default color of the required field validator. In the source it is:
<span class="required">*</span>
<asp:RequiredFieldValidator ID="valReq_txtTracks" runat="server"
ControlToValidate="txtTracks"
Display="Dynamic" />
Here's what I have in my .skin file:
<asp:RequiredFieldValidator runat="server"
CssClass="error-text"
ErrorMessage="required" />
In the rendered source I see:
<span class="required">*</span>
<span id="ctl00_ctl00_cphContent_cphContent_valReq_txtTracks" class="error-text" style="color:Red;display:none;">required</span>
Notice the "style=color:Red;". That needs to go. I can't override it with a css-class because it's inline CSS. What should I do?
There is a RequiredFieldValidator.ForeColor property you can set to control the color. Note that if you want to set the color in CSS, then you need to set ForeColor="" to clear it on the control.
I know this an old thread, but I ran into this another day. It's kind of odd that setting style sheet does not override the text color of the validator. In my case, I had a whole bunch of different validators and extended validators that I wanted to override text color for, so instead of a theme and skin file, I created custom control adapter that handles rendering of BaseValidator control. Inside the rendering method, I just set ForeColor = Color.Empty. Hopefully this helps other people who ran into this situation and want to override text color for all kind of validators (required field, regular expression, compare,...).
Did you try to add style attribute with empty string in the skin file:
<asp:RequiredFieldValidator runat="server"
CssClass="error-text"
style=""
ErrorMessage="required" />
I read somewhere to use the !important tag in your css class to override the inline css...
Using !important seems to work fine in Firefox and IE, but for some reason not in Google Chrome... no biggie though, Chrome's share is still very low.
.form_error
{
font: bold 15px arial black,arial,verdana,helvetica !important;
color: #ff0000 !important;
}

Resources