In The Page_Load event of an ASP.NET USercontrol, I have the following Code:
If Not Page.ClientScript.IsClientScriptIncludeRegistered("ProperCase") Then 'doesnt seem to work but no apparent harm.
Page.ClientScript.RegisterClientScriptBlock(GetType(String), "ProperCase", GetJavaProperCase())
End If
And here's a function that was called from above:
Private Function GetJavaProperCase() As String
Dim Buffer As String = ""
Buffer &= "function toProperCase(s) {" & vbCrLf
Buffer &= " return s.toLowerCase().replace(/^(.)|\s(.)/g," & vbCrLf
Buffer &= " function($1) { return $1.toUpperCase(); });" & vbCrLf
Buffer &= "}" & vbCrLf
Buffer &= "" & vbCrLf
Return Buffer
End Function
When I view the emitted HTML, I see that the script is OUTSIDE of the script tags.
<script src="/BESI/WebResource.axd?d=HNVlrg1DODlFCdCw68ANPg2&t=633753469952786250" type="text/javascript"></script>
function toProperCase(s) {
return s.toLowerCase().replace(/^(.)|\s(.)/g,
function($1) { return $1.toUpperCase(); });
}
Any idea why?
Edit:
Why is there a SRC attribute on the SCRIPT tag? That doesn't look right.