Hello,
In my view, I generate the HTML, and add some jQuery/Javascript code. The view is displayed in a div of my main page. The jQuery code I added is there but not working. When I place the same code directly hard-coded in the view that's work. In my view, it's as partial view (.ascx) I have something like this :
<%= Model.GetMyScript() %>
Thanks,
Update 1 In my main page I have a menu section with hyperlink. In this partial view (not the same than the other), I create some link :
<h2>Category</h2>
<ul>
<% foreach (Category item in Model.Categories) { %>
<li><%= Model.DisplayURL(item) %></li>
<% } %>
</ul>
DisplayURL
public string DisplayURL(Category category)
{
return string.Format("<a href=\"#\" onclick=\"MyFunction('{1}')\">{0}</a>", category.Code, category.Code);
}
When I add this at the end of partial view :
<script type='text/javascript' language='javascript'>
function MyFunction(data){
alert(data);
});
</script>
but the same code added in the view by programming is not running.
Error I receive : http://tinypic.com/r/55ms1l/6