Reputation: 79
I am trying to call a particular div based on id in page_prerender
event but it doesn't navigate to the particular div id.
<div id="div1">1</div>
<div id="div2">2</div>
<div id="div3">3</div>
protected void page_prerender()
{
Response.Redirect("Default.aspx#div1");
}
Upvotes: 0
Views: 1384
Reputation: 79
Please put runat="server"
. So, that you will able to access it on code behind
<div id="div1" runat="server">1</div>
<div id="div2" runat="server">2</div>
<div id="div3" runat="server">3</div>
Thanks
Upvotes: 0
Reputation: 15253
Use the FindControl method to locate the div - pass id of div as argument.
<div id="div1" runat="server">1</div>
FindControl("div1");
Upvotes: 2
Reputation: 3198
with jQuery Alternatively you can use this to scroll to specific element on page load with animation: try this on aspx page
$(function(){
$('html, body').animate({ scrollTop: $("#div1").offset().top });
});
Upvotes: 0