Setting up Relative path for script tag

the tags with out runat attribute will not allow us to set relative path like

“~/script/xyz.js”

to over come this issue you have to create the tag at runtime in the page load event like this.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         Dim js As HtmlGenericControl = New HtmlGenericControl("script")
       js.Attributes.Add("type", "text/javascript")
       Dim s As String = "~/js/jquery.js"
       s = s.Replace("~", Request.ApplicationPath)
       js.Attributes.Add("src", s)
       Page.Header.Controls.Add(js)
   End Sub

again you will be facing one problem is that the script tag generated will be added at the end of the header if you have a function which is going to use the referenced script library will give you javascript error.

once again a not so good solution is put your script inside the body of the page . now everything will works fine.

Authorization for essential folders

While using form based security in asp.net you will use role manager and membership providers, to enable rules based access for your web pages.

Care should be taken that you have to place web.config files in all your themes, scripts folder and other folders which you feel necessary for the start up load with authorization enabled to all users like this

<?xml version="1.0"?>

<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</configuration>

 

other wise those important features  like css or themes will be not be seen until you are logged on with administrative privilege.

HTH

Another Quick Tip on Sys.WebForms.PagerequestManagerParserError

I have got this error off late , i tried googling around and found a lot of resources regarding this error, but i think each and every time the error seems to have reincarnating itself into different forms, in my case the error explanation was unknown error , blah blah 
.. server returned 404 .  in the first 10 searches doesn’t seem to return my case

scenario : this error only occurs on ajax 1.0 with asp.net 2 update panel

remedies suggested: remove any response.write or server.transfer inside the update panel , disable trace in web.config, prevent httpmodule from rewriting part of response or prevent response filter from rewriting part of response

in my case i am using a gridview inside an update panel which has edit button update and cancel button which is rewriting the response.

solution : i changed the triggers of the update panel to postback from asynchronous postback , but it compromises the effect of updatepanel itself , but i have to live with that one ,

strange enough this occurs only in ie5+ and not in Firefox 3.5

links of interest regarding this error is : http://forums.asp.net/t/1038252.aspx

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx

 

HTH 🙂