How To Redirect On Same Page Area On Button Click Without Postback?
On clicking button I want users to be redirected to some specific area in same page. I know it can be done with using anchor tags but not sure how will it possible with asp.button.
Solution 1:
Use an <a href="#xxx">
tag, where xxx
is an <a name="xxx">
tag somewhere in your page.
Solution 2:
The easy way, with out any check, just use javascript to add the anchor at the end of the link .
<asp:ButtonID="Button1"runat="server"OnClientClick="document.location.href+='#locA';return false;" />
and it will navigate to position of the : <a name="locA"></a>
and the correct way, that you can make many clicks with diferent anchors.
<script>functioncGoTo(where)
{
// take care if any other anhor exist to remove it.var url = document.location.hrefvar tempArray = url.split("#");
var baseURL = tempArray[0];
document.location.href = baseURL + "#" + where;
}
</script><asp:ButtonID="Button2"runat="server"OnClientClick="cGoTo('locA');return false;" />
And one online test: http://jsfiddle.net/r3Sav/
Post a Comment for "How To Redirect On Same Page Area On Button Click Without Postback?"