When should the .Header.DataBind page be called?

I am trying to resolve the correct paths to javascript scripts in my section of the chapter using:

<script src="<%# ResolveUrl("~/Scripts/jquery-1.4.2.min.js") %>" type="text/javascript" />

To solve the path, I need to call the databind with Page.Header.DataBind();Which event should I put in the data binding call?

Thank.

Link: http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/

When I put it in Page_Load, as the article suggests that it works (only for firefox), but I wonder if this place is right.

When I follow this article, IE 8 displays:

<script src="/Scripts/jquery-1.4.2.min.js" type="text/javascript" />

and firefox 3.6 displays correctly:

<script src="../../Scripts/jquery-1.4.2.min.js" type="text/javascript" />

Update:

, script , ResolveUrl. . , Databind.

+5
3

ID and runat="server" ( ), , databind .

0

<%# <%=, Page.Header.DataBind();, .

. ASP.NET.

, :

<script type="text/javascript" src='<%= ResolveUrl("~/js/jquery-1.4.2.min.js") %>' ></script>
+2

I managed to solve this problem for myself by calling Page.DataBind()on Page_Load.

Update: just calling it on Page_Loadthe main page caused some errors with gridview commands not working. Checking !Page.IsPostBackcorrects this.

0
source

Source: https://habr.com/ru/post/1768507/


All Articles