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

Use server side variable in aspx design using <%= servervariable %>

1 Answer 392 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kalpesh
Top achievements
Rank 1
Kalpesh asked on 27 Dec 2013, 07:18 AM
Hi Team Telerik,

We have recently started using Telerik for our product. In our application, we have used scripting to use server side variables at hundreds of places. For example as below.

<a id="lnk1" class="xyz" href="abc.aspx?ReturnPath=<%= returnPath %>">Test</a>

Now, as we have introduced Telerik, we were facing issues around this. By browsing the documentation, we come to know that - we can use RadScriptBlock to avoid this. But I understand that it is only in case if we have script block and any server side variable we are using inside it.

I also gone through this and this posts, but I couldn't really understand what to do. Please assist.

One case I would like to share is, I have placed link (above mentioned code snippet) inside list view Layout Template. I have tried to add RAD script block around it. It worked fine for loading page. But, when I do paging, nothing happened and I observed below JS error

Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: The script tag registered for type 'System.Web.UI.Page' and key 'RadListView1$RadScriptBlock1' has invalid characters outside of the script tags: <a id="lnk1" class="xyz" href="abc.aspx?ReturnPath=s%3d301%26c%3d3%26d%3d%26p%3d1%26">Compare</a> . Only properly formatted script tags can be registered.
     
 
...._validPosition(a.scrollLeft)||this._validPosition(a.scrollTop)))return {x:a.scr...

Any assistance will be greatly appreciate.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 01 Jan 2014, 01:28 PM
Hello Kalpesh,

I was able to replicate the error that you are observing, when I have placed the link within RadScriptBlock and ajaxified RadListView.

Please note that RadCodeBlock should be used instead. Here is a simple example of a LayoutTemplate:
<LayoutTemplate>
    <fieldset style="width: 910px;" id="FieldSet1">
        <legend>Products</legend>
        <asp:Panel ID="ProductsHolder" runat="server">
        </asp:Panel>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <a id="lnk1" class="xyz" href="abc.aspx?ReturnPath=<%= returnPath %>">Test</a>
        </telerik:RadCodeBlock>
    </fieldset>
</LayoutTemplate>

Additionally, you could also try using the following:
<LayoutTemplate>
    <fieldset style="width: 910px;" id="FieldSet1">
        <legend>Products</legend>
        <asp:Panel ID="ProductsHolder" runat="server">
        </asp:Panel>
        <a id="lnk1" class="xyz" href="abc.aspx?ReturnPath=<%# returnPath %>">Test</a>
    </fieldset>
</LayoutTemplate>

Hope that helps.


Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
General Discussions
Asked by
Kalpesh
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or