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

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
 
B

bruce barker

<%# %> 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)
 
A

AAaron123

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top