div to redirect via code behind
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.
精彩评论