HTML Encoding

6 posts, 1 answers
  1. Andy Green
    Andy Green avatar
    120 posts
    Member since:
    Jul 2009

    Posted 03 Aug 2009 Link to this post

    Hi

    My Schedule is currently showing data from a database in the appointment section. This data contains HTML, but the tags are being shown and are not being rendered as HTML. Is there a HTMLEncode equivalent like bound colunms on Rad / data grids.

    This is what is displayed:QEH <br/> BWH <br/> DCC
    This is the view source:QEH &lt;br/&gt; BWH &lt;br/&gt; DCC
    This is what I want:
    QEH
    BWH
    DCC

    Or is there another way to achieve this.

    Andy
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 03 Aug 2009 Link to this post

    Hi Andy,

    You can easily workaround this problem using AppontmentTemplate:

     <AppointmentTemplate> 
            <asp:Panel ID="Panel1" runat="server">  
            </asp:Panel> 
        </AppointmentTemplate> 

    protected void RadScheduler1_AppointmentCreated(object sender, Telerik.Web.UI.AppointmentCreatedEventArgs e)  
        {  
            string[] subjectArray = Regex.Split(e.Appointment.Subject, "</br>");  
            Panel subjectPanel = e.Container.FindControl("Panel1"as Panel;         
              
            foreach (string subPart in subjectArray)  
            {  
                Literal subjectLine = new Literal();  
                subjectLine.Text = subPart + "</br>";  
                subjectPanel.Controls.Add(subjectLine);             
            }  
        } 


    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 03 Aug 2009 Link to this post

    Hi again Andy,

    I don't know why I went this way for a workaround, when actually there is a much simpler solution:

    <AppointmentTemplate> 
            <%# Eval("Subject") %> 
        </AppointmentTemplate> 

    Sorry for the unnecessarily complicated previous solution.


    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Andy Green
    Andy Green avatar
    120 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Hi Team

    Things have change with this, and the scheduler now sits inside a repeater control. But......

    Neither proposed option works,
    With the first option it fails because the with events refers to the control that is wrapped inside the repeater and it cant find it.
    'Handles clause requires a WithEvents variable defined in the containing type or one of its base types'

    The second method - The data I wish to show is created for the RadScheduler, ie the repeater has a datafield value for week number, this week number is passsed into the itemcreated to get the appointment data for the scheuler, so this wont work either.

    How can I achieve this with my current set up.

    Andy
  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 03 Sep 2009 Link to this post

    Hello Andy,

    This is a VB.NET problem. The solution which I found in the forums is to set the event handler declaratively:

    * * *  
     
    <telerik:RadScheduler runat="server" ID="RadScheduler1" OnAppointmentCreated="RadScheduler1_AppointmentCreated">  
     
    * * * 

    and to remove "Handles RadScheduler1.AppointmentCreated" from the event handler:

    Protected Sub RadScheduler1_AppointmentCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.AppointmentCreatedEventArgs)  
     
    End Sub 


    Regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Andy Green
    Andy Green avatar
    120 posts
    Member since:
    Jul 2009

    Posted 03 Sep 2009 Link to this post

    Brilliant - thank you.

    BTW - I do search the forums before I post, but I guess it's knowing what to search for.

    Andy
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017