This is a migrated thread and some comments may be shown as answers.

[Solved] html rendering

4 Answers 185 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sunil
Top achievements
Rank 1
sunil asked on 04 Mar 2010, 04:43 AM
For this page:http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx
For method:
RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

when I'm adding items in via:
RadComboBox1.Items.Add(new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString(), data.Rows[i]["CompanyName"].ToString()));

It does not render the text of the item as HTML (basic stuff like an <i>, <b> and maybe <br/>). It just prints out the HTML tags as text. How can I make it such that the text of the item renders as HTML?







4 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 04 Mar 2010, 12:27 PM
Hello sunil,

As I understand you are trying to set an html string as Text property of a RadComboBoxItem and display it in the input or in the dropdown.
The RadComboBox has a build-in html encode/decode mechanism so there is no way to render html in its input.

Let me suggest you use css styles to customize the appearance of the RadComboBoxItems. Here you can find detailed information about this topic.

An alternative approach is to use ItemTemplate of the RadComboBox - you can add html in it and it will be rendered properly at the control dropdown. More about templates you can find here.

Regards,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
sunil
Top achievements
Rank 1
answered on 04 Mar 2010, 02:59 PM
But what seems odd is that HTML rendering is fully supported when using RadComboBoxData. In the same example, the function:
        [WebMethod]
        public static RadComboBoxData GetCompanyNames(RadComboBoxContext context)
        {


Fully supports html rendering in the RadComboBox display. I tested it and it works.

But then another problem arises when using webmethods, since
<WebServiceSettings Method="GetCompanyNames" Path="Products.asmx" />
There is no support for a contextkey member, which I need. I don't understand why there is no support for it - regular AJAX fully supports a contextkey. I need more than just the text in the textbox connected to the radcombobox. I need a contextkey - for example, I need the text in the textbox connected to the radcombobox as well as say, the "ticket ID number" of the aspx page that I am on, so that it query the database on what data is not already associated with the "ticket ID number" in the database.

Either way is not working.


0
sunil
Top achievements
Rank 1
answered on 04 Mar 2010, 03:05 PM
Look actually within the <WebServiceSettings Method="GetCompanyNames" Path="Products.asmx" />
if I didnt have to use an asmx file (because of the problem with contextkey), I could just add the webmethod into my .aspx.cs page, then I wouldn't need a contextkey. But how can I do that? If both the radcombobox control and the webmethod are both in a file called test.aspx.cs, how do I reference test.aspx.cs via the "Path" of the webservicesettings?

If you can answer this, my problem is somewhat resolved.
0
Kalina
Telerik team
answered on 09 Mar 2010, 12:39 PM
Hi sunil,

Please take a look at this online example  at the third RadComboBox ("Page methods") the page and method are referred at the Path property:
<WebServiceSettings Method="GetCompanyNames" Path="defaultcs.aspx" />

Then at code behind GetCompanyNames method is marked as [WebMethod]:
[WebMethod]
public static RadComboBoxData GetCompanyNames(RadComboBoxContext context)
{
 // method logic here ...
}

In fact you can easily add a context key to pass a context information to the server.
More details about loading items from a web service you can find at this article.

Greetings,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
sunil
Top achievements
Rank 1
Answers by
Kalina
Telerik team
sunil
Top achievements
Rank 1
Share this question
or