I have an asp.net website, in which I need to change the textbox font depending upon the language selected by the user.There are 2 radio buttons for 2 different languages English and Hindi.When the user selects one of these languages,the textbox font is changed through the following piece of code:
if(rbEnglish.Checked==true)
{
TextBox1.Font.Name="Times New Roman";
}
else if(rbHindi.Checked==true)
{
TextBox1.Font.Name="Shivaji05";
}
This works on the local computer but when the website is hosted,the Hindi font does not appear.What should be done to get this working?
Your question is strange; I think you made a simple mistake. Did you check your website with some developers tools like FireBug(in firefox), be sure that your text box gets your font style; there may be a css style in your host that overrides your internal style with somthing like "!important". Another possibility, Are you sure that you are visiting it on a client that has your Hindi font? Are you updating your text box with asp:UpdatePanel? does it work fine for other activities?
Related
I have a little help pop-up that displays some text when the user presses a "?" label next to a drop-down to explain the different selections.
I did it using the Help.ShowPopup command since that seemed the easiest.
I was hoping there was a way to add different font properties to parts of the text or at least to the whole thing without having to go the direction of a CHM/HTML help-file.
Here is what I am trying to do:
private void helpLbl_Click(object sender, EventArgs e)
{
// for some reason, it ignores the 'parent' parameter
// and lays it out on the screen's coordinates
Point helpLocation = helpLbl.PointToScreen(Point.Empty);
helpLocation.Y += helpLbl.Height; // have it display underneath the control
Help.ShowPopup(this, // hosting form
#"<b>Fixed:</b>
Removes a fixed amount from the sale
<b>Percent Value:</b>
Removes a set percentage of the selected package from the sale
...", helpLocation);
I was hoping since there's the option to use an HTML document to display the help, I could use HTML tags to format what was being displayed, but it doesn't appear so. Any ideas?
Is there a way to do something like displaying a RichTextBox in the help pop-up?
Another possibility is generating a HTML document on-the-fly, but it asks for a "url" if I'm not supplying the text directly and I think that might be a little over-kill for the small amount I'm trying to do here.
You have two options. One is to use a WebBrowser Control. This natively accepts HTML and displays it. The problem with it is its kind of bloated just to use as a simple label.
Your second option is to simply create a RichTextLabel, simply like this:
public class RichTextLabel : RichTextBox
{
public RichTextLabel()
{
BorderStyle = BorderStyle.None;
}
}
Add this to your form and set the Rtf property to your RTF code. You will have to convert your HTML to RTF, which is easy if you got a program such as Microsoft Word, for example.
I have a text which may contain some special characters like <b></b> or a link. I want the user to be able to click on the link and open it. TextBlock or RichTextBox seems doesn't show links in a proper way:
<RichTextBox >
<Paragraph>
click here: http://www.google.com
</Paragraph>
</RichTextBox>
How can I show a text like that in a page?
Update: seems my question isn't clear. I ask a server for content and it returns back to me something like this:
from <b><i><a href="http://www.google.com" rel=nofollow> lorem ipsom
NPR:
tapped in front of you probably know Bill Gates...
I want to show this in a WINDOWS PHONE page. TextBlock doesn't render it well. how can I show it human readable?
The way to solve your problem I see in using of WebBrowser control.
Then, accordingly to the article, you should go with Javascript to manage the links clicking etc (unless you want the links would be opened automatically with standard logic of Windows Phone):
Script is disabled in the WebBrowser control by default. Set the
IsScriptEnabled property to true if you want to enable scripting in
your control. You can then call scripts using the InvokeScript method.
The ScriptNotify event occurs when JavaScript in the WebBrowser
control passes a string to managed code.
That's a bit tricky way, but if you want to go any other way, you would have to implement your own parser of the code and build the sentence with labels and custom hyperlinks (as in provided above suggestions from comments).
I am trying to perform edit functions in a RichTextBox on a C# (Windows Forms) application and .NETFramework 3.5. I would like to be able to select any number of text characters from all text present on the RichTextBox and then change targeted font characteristics.
The trouble I have is that on my selected text each characters font properties may be set to different font. In this case the textbox ignores the event that I request.
case "Font Size": ComboTool = (Infragistics.Win.UltraWinToolbars.ComboBoxTool)this.RTFUltraToolbarsManager.Tools["Font Size"];
try
{
this.RichTextBox.SelectionFont = new Font(this.RichTextBox.SelectionFont.Name, float.Parse(ComboTool.Text), this.RichTextBox.SelectionFont.Style);
}
catch { }
break;
When I do that in my "RTFUltraToolbarsManager_ToolValueChanged", I want to change te size of the selected text and the "this.RichTextBox.SelectionFont" is null.
Do you know how can I solve my problem?
In my application I have a rich text-box.I use that as a text editor. I can change font,size, style when I needed. now my problem is I want to find out font-name,size, text-color of each character ?
i,e i want to retrieve every character's font-name,size, text-color after editing is done.
You can use the SelectionFont property to retrieve the font of the currently selected text. Similarly, you can use the SelectionColor property.
Never done this personally and no time to test at the moment, but the: Groups RV's DotNET forum may have your solution. Perhaps something like mentioned in the post:
for (int iCurChar = lastChar; iCurChar
richTextBox1.Text.Length; iCurChar++)
{
richTextBox1.Select(iCurChar,1);
char CurrChar = richTextBox1.Text[iCurChar];
Color CurrColor = richTextBox1.SelectionColor;
Font CurrFont = richTextBox1.SelectionFont;
float fontSize = CurrFont.Size
}
Taking a look at the Font class may be useful as well: Microsoft's Font Reference Page
I am building a mobile site and the footer has an background.
I want to check if the browser supports css property, background-image, if true display background with specific html, else display a different set of html.
I am using the following :
HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
I can't seem to get a check for backgrounds.
The reason why I want to check for BG-image support is coz I have to switch between 2 sets of html. 1 with html text and bg image, and the other with the text on the image - sliced for each word/link...to give the same effect.
to get information by HttpBrowserCapabilities, you have to use Request.Browser property.
HttpBrowserCapabilities browerCapabilities = Request.Browser;
I think Asp.net will automatically check the type of the browser and render the page accordingly. So if the the browser don't support background images it will not come.
Another idea to solve the issue is getting the browser type by using code, then you can show or hide the background images based on the type.