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

[Solved] Rendering ScriptRegistrar at the end of the file and xVal validation

4 Answers 149 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
GrZeCh
Top achievements
Rank 2
GrZeCh asked on 19 Nov 2009, 01:35 PM
Hello,

I'm trying to use javascript validation (using xVal):
<%= Html.ClientSideValidation("contactform"typeof(ContactForm)) %> 

but I'm getting error "xVal is not defined" which is understandable because it is being added at the end of the file where I'm running Render() function. When I try to run Render() in page head section Telerik Menu and PanelBar are not working (I'm not getting any JS errors in Firefox and other scripts are working -> xVal too). Any ideas how to fix this issue?

Thanks

4 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 19 Nov 2009, 02:44 PM
Hello GrZeCh,

You can move the ScriptRegistrar to the top (where you want jQuery to be available) and include the grid and menu scripts manually at the end of the page. This is not advised from a performance point of view (i.e. you should always include the scripts at the bottom of the page) - yet I am not aware if xVal has some way of delayed startup.

Kind regards,
Alex
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.
0
GrZeCh
Top achievements
Rank 2
answered on 19 Nov 2009, 03:13 PM
I was trying to do something like this:
                <% Html.Telerik().ScriptRegistrar() 
                  .OnDocumentReady(() => 
                  { 
                      Html.ClientSideValidation("contactform", typeof(ContactForm)); 
                  }); 
                %> 

but this is not showing in page source in browser.
0
Alex Gyoshev
Telerik team
answered on 19 Nov 2009, 03:19 PM
Hi GrZeCh,

It should be like this:

<% Html.Telerik().ScriptRegistrar()
  .OnDocumentReady(() =>
  {%>
      <%= Html.ClientSideValidation("contactform", typeof(ContactForm)) %>
  <%});
%>

(or, of course, use Response.Write)

The ClientSideValidation helper returns string.

Kind regards,
Alex
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.
0
GrZeCh
Top achievements
Rank 2
answered on 19 Nov 2009, 03:57 PM
This is solution to my problem:

<% Html.Telerik().ScriptRegistrar() 
  .OnDocumentReady(() => 
  {%> 
      <%= Html.ClientSideValidation("contactform"typeof(ContactForm)).SuppressScriptTags().ToString() %> 
  <%}); 
%>  

I didn't have to move anything from page bottom.
Tags
General Discussions
Asked by
GrZeCh
Top achievements
Rank 2
Answers by
Alex Gyoshev
Telerik team
GrZeCh
Top achievements
Rank 2
Share this question
or