开发者

div to redirect via code behind

开发者 https://www.devze.com 2023-02-21 09:06 出处:网络
Hey guys I cant seem to get this to work: div.Attributes.Add(\"UserFriendsWall.aspx?FriendID=\" + Server.UrlEncode(id));

Hey guys I cant seem to get this to work:

div.Attributes.Add("UserFriendsWall.aspx?FriendID=" + Server.UrlEncode(id));

Also tryed this:

div.Attributes.Add("onclick", "UserFriendsWall.aspx?FriendID=" + Server.UrlEncode(id));

Is ther开发者_Python百科e anyway to redirect while storing id?

maybe

div.Attributes.Add("onclick", "redirect(" + id + ");");

this is only a means if there is no other way with c#

<script type="text/javascript">
    function redirect(id) {
        redirct function via javascript maybe, dont know how tho?('DivClicked', id);

    }


</script> 


I think what you want is

div.onclick = function () {
  location = "UserFriendsWall.aspx?FriendID=" + encodeURIComponent(this.id);
};

Or if id is a variable in local scope, drop the this. from the front.


I'm not sure if it'll fix your problem, but you need to tell javascript that it should redirect, i.e.: window.location.href="UserFriendsWall..." . At the moment you're just passing a string, which doesn't do anything.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号