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

Emitting HTML From Server To Client

1 Answer 33 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 05 Oct 2011, 05:08 PM
All,

    In certain cases I'll have a WEB Method that will send HTML down to the Client.  For example:
[WebMethod]
public static string EmitHtml(string Msg) {
    return "<div style=\"height:100px; width:100px; background-color: #808000;\">\" TEST \"</div><br/>";
}

Then on the Client in my JavaScript I'll either use jQuery or straight JavaScript to do something like this:
function onGotHtml(Html) {
    $get('divContainer').innerHTML = Html;
}


My question is:  Can I do something similar with the Telerik controls?  Or is this approach soley limited to simple HTML controls?

1 Answer, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 07 Oct 2011, 09:50 AM
Joe, 

If you mean can you do something like this ...

public static string EmitHtml(string Msg) {
    return "<telerik:RadButton>\" TEST \"</telerik:RadButton><br/>";
}

Then the answer is no.

However, you can inject controls dynamically from your code behind. So, if you have, say, an asp:Panel called 'Panel1' on your page, you could do this...

RadButton btn = new RadButton();
btn.ID = "someID";
btn.Text = "Click Me";
Panel1.Controls.Add(btn);

If you google "adding asp.net controls dynamically" you will find, quite literally, millions off examples (more than 27 million when I just did it).

-- 
Stuart
Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Stuart Hemming
Top achievements
Rank 2
Share this question
or