'<%#Server.UrlEncode("Events_View.aspx") %>' returns ''

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

I've learned a lot in this NG recently. I learned about <%# and about
UrlEncode but apparently not quite enough.

I want to open the page Events_View.aspx when a button is clicked, so I
tried:

<input type="button" value="Return to Event"
onclick="window.location='<%#Server.UrlEncode("Events_View.aspx") %>'" />

Debugging show that the resulting markup is:

<input type="button" value="Return to Event" onclick="window.location=''" />

Can you see what is wrong with my statement?

Also reading about window.location I don't see the difference between:

window.location="EventsView.aspx")

and

window.location.href="EventsView.aspx")

Is there a difference?



Thanks
 
<%# %> is a binding expression. you probably are not calling databind.

window.location is an object (browser, not javascript) with properties.
but if set to a string url, the new object is created and navigation is
performed.

-- bruce (sqlwork.com)
 
I hope this fixes the difference between
<%= and <%# in my mind.



bruce barker said:
<%# %> is a binding expression. you probably are not calling databind.
I hope this fixes the constructs
<%= and <%# in my mind.



window.location is an object (browser, not javascript) with properties.
but if set to a string url, the new object is created and navigation is
performed.
Setting the href property does the same thing?
They seem to work indentically in this instance.

Thanks
 
Back
Top