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

Discussion in 'ASP .Net' started by AAaron123, Mar 23, 2009.

  1. AAaron123

    AAaron123 Guest

    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
     
    AAaron123, Mar 23, 2009
    #1
    1. Advertisements

  2. AAaron123

    bruce barker Guest

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

    AAaron123 wrote:
    > 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
    >
    >
    >
    >
     
    bruce barker, Mar 24, 2009
    #2
    1. Advertisements

  3. AAaron123

    AAaron123 Guest

    I hope this fixes the difference between
    <%= and <%# in my mind.



    "bruce barker" <> wrote in message
    news:...
    > <%# %> 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

    >
    > -- bruce (sqlwork.com)
    >
    > AAaron123 wrote:
    >> 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
    >>
    >>
    >>
     
    AAaron123, Mar 24, 2009
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    4
    Views:
    10,409
    mikeb
    Jan 22, 2004
  2. msn

    Server.UrlEncode error???

    msn, Feb 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    492
  3. Dario Sala
    Replies:
    1
    Views:
    3,933
    Karl Seguin
    Nov 15, 2004
  4. Nathan Sokalski

    Strange results from Server.UrlEncode

    Nathan Sokalski, Jun 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    396
    Nathan Sokalski
    Jun 8, 2005
  5. MyndPhlyp
    Replies:
    3
    Views:
    526
    MyndPhlyp
    Oct 3, 2005
Loading...

Share This Page