Reputation: 6090
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 there 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>
Upvotes: 0
Views: 1489
Reputation: 120526
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.
Upvotes: 2
Reputation: 5362
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.
Upvotes: 0