I have a textbox control (multi-line enabled). Is that possible to assign it a background image?
I'm assuming this is a WinForms application?
There is no 'built-in' way of doing this. You can override the controls paint method (onPaintBackground - I believe) and draw the image yourself.
If it's Web based or WPF - you're in luck.
It's possible. Just add the image location to the text box styling:
<asp:TextBox id="TextBox1" runat="server" style="background-image: url( images/myTextboxImage.jpg ); border: none;" />
EDIT: As Rob pointed out in his answer: this is only if you're doing it on the web.
Related
I asked on Telerik's site, but there is apparently not enough traffic there to generate answers.
I am trying to convert an asp ImageButton to a RadImageButton because there are some useful features that would make my life a bit easier. However, the binding for the image URL won't work - at least the way I am doing it.
So this works (both are in the same ListView):
<asp:ImageButton ID="im" runat="server" ImageUrl='<%# Eval("ImgUrl") %>' />
But this:
<telerik:RadImageButton runat="server" ID="itemImageButton" '>
<Image Url='<%# Eval("ImgUrl") %>' />
</telerik:RadImageButton>
gives me an error something like Telerik.Web.UI.ButtonBase.ButtonImage does not have a DataBinding event.
If someone could point me in the right direction to get this done with the RadImageButton control (if possible), I would appreciate it.
I was recently facing exactly the same issue. Apparently child objects/properties in some controls are not DataBound-able.
You have to do the binding for the image URL inside the telerik:RadImageButton tag itself, so instead of using <Image Url="" /> section, place it in the Image-Url attribute:
<telerik:RadImageButton runat="server" ID="itemImageButton" Image-Url='<%# Eval("ImgUrl").ToString() %>'>
</telerik:RadImageButton>
You can ommit .ToString() part though.
One more "issue" that I've got when switching from asp:ImageButton to telerik:RadImageButton was the necessity to set the width and height explicitly. Without it, it didn't work ouf of the box. Image (icon) was malformed, even though it was like 24x24 sized. I ended up setting width="" and height="" attributes, but adding CssClass and using styles should work too.
Simple question really. How can I change the background color of the CKeditor from C#?
How do I get an instance of CKeditor in C#? Probably I cannot?
I have a gridview with lots of textareas (asp:textbox) controls all using the CKeditor, via the CSSclass property, and it works great! But now I want to dynamically change one or two, or all of their background colours to something like LightYellow.
I've tried to directly change the background of the asp:textbox, but it doesn't work of course because that's "hidden" from the CKeditor itself.
Any other tips please?
UPDATE
I've downloaded the CKEditor for ASP.net and it too does not work, as it also creates a textarea element in the background automatically - effectively the same as using the CKeditor natively with CSSclass="".
Referencing the control in C#, I can do that now, which is great so I can get the data and use it in my database, but I still cannot change the CKeditor's background. The CKeditor's BODY element (tested via FireBug), is the one I need to change, but how from C#?
Thanks again
First, be sure you have installed both CKEditor and CkeditorForASP.NET packages via Nuget.
Afterwards, create an editor.css file which will contain only editor related styles such as:
.lightYellow {
background-color: lightyellow;
}
On your grid view, bind to OnRowDataBound event and specify base path of CKEditor scripts correctly.
<asp:GridView ID="EditorGridView" runat="server" OnRowDataBound="EditorGridView_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<CKEditor:CKEditorControl ID="Editor" runat="server" BasePath="~/Scripts/ckeditor" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then you will be able to change the body color as follows:
if (e.Row.RowType == DataControlRowType.DataRow)
{
CKEditorControl editor = (CKEditorControl)e.Row.FindControl("Editor");
editor.BodyClass = "lightYellow";
editor.ContentsCss = ResolveUrl("~/Content/editor.css");
}
I have a tab panel where i have used "ajax__tab_xp" default css class.BUt i want to set the background color with the existing css class.
My code:
<asp:TabContainer ID="TabContainer2" runat="server" Height="258px" Width="100%" ActiveTabIndex="0" TabStripPlacement="Top" CssClass="ajax__tab_xp" useverticalstripplacement="true" verticalstripwidth="100px">
.ajax__tab_xp .ajax__tab_body {font-family:verdana,tahoma,helvetica;font-size:10pt;border:1px solid #999999;border-top:0;padding:8px;background-color:#ffffff;}
I have almost tried every possibilities but it is not working.
apply !important to property like:
.ajax__tab_xp .ajax__tab_body {font-family:verdana,tahoma,helvetica;font-size:10pt;border:1px solid #999999;border-top:0;padding:8px;background-color:#ffffff !important;}
I have FileUpload Control on my Page:
<asp:FileUpload runat="server" ID="fuAttachment" CssClass="fileUploadCSS" size="76" />
I want to change size of this Control on Button's Click event though Jquery.
How do i set it? because ($("#fuAttachment").size doesn't working. and ($("#fuAttachment").width returns null
Thanks in Advace
Try this for your button onclick method:
$('#fuAttachment').css('width',200);
You can find more information about the jQuery css method here
Update
During my conversation with devjosh i came up with this line of code
$('#fuAttachment').attr('size', 50);
It seems that the size attribute is much more supported in modern browsers than change the css width property.
You cann see a working example here: http://jsfiddle.net/CY3jG/1/ (Tested in IE 8 and FF 9)
You have control over various elements of the FileUpload control's style. For design purposes you may want to temporarily add a solid border, it will give you a better perspective to see how the width is actually adjusted. In FireFox and Chrome there is no border around the textbox of the FileUpload control, there is for IE. Without the border it appears that width doesn't change in FF, Chrome. For example, the script below changes font size, background color and the width (which will be clear with a border added).
<script>
$(document).ready(function() {
$("#FileUpload1").css('font-size', '25');
$("#FileUpload1").css('background-color', 'red');
$("#FileUpload1").css('border', 'solid');
$("#FileUpload1").css('width', '800');
});
</script>
Hope this helps.
When I set Enabled to false, it sets the background of the textbox to a grey color, can this be changed? Right now, the grey background with black text makes it a little hard to read.
Or maybe, I have to use the readonly property instead and set the backcolor myself, is this correct?
There are several ways to achieve this:
1) Use CSS to change the look for all the input controls. Just put "input[disabled] { border:solid 1px red; }" in your CSS file.
2) Using ASP.NET skins, in the Skin file you could write:
<asp:TextBox runat="server" SkinID="disabled" CssClass="disabled"></asp:TextBox>
This would set the disabled CSS class only for that TextBox
3) Manually assigning a CSS class to only the TextBoxes you want disabled, like:
<asp:TextBox runat="server" ID="x" Enabled="false" CssClass="disabled"></asp:TextBox>
4) Create your custom control that inherits from TextBox and configure it that way.