Jump to bookmark

I have an online web application, in the form, there is a field for people to enter how many block they need for work experience, when people enter a number and hit the link button, the blocks will be generated. everything works fine, however, when people hit the link button, the form jump to the beginning of the form, what I need is it should jump to the bookmark where the blocks are created. Please help. Here is my code. THanks

My bookmark is
<a name="Create_block">Create block</a>

My sub is

Sub lnkCreateBlock (s as obect, e as eventargs)
        CreateBlock(intNumBlock)
        'I tried to add something like
        'lnkCreateBlock.Attributes.Add("onlick","<a href=""#Create_Block""></a>")
        'but it's not working
End Sub
CochiseCountyAsked:
Who is Participating?
 
appariCommented:
i forgot to add script tags,

Sub lnkCreateBlock (s as obect, e as eventargs)
        CreateBlock(intNumBlock)
        Page.RegisterStartupScript("ShowBlock", "<script language=JavaScript>location.href='#Create_Block';</script>")
        'I tried to add something like
        'lnkCreateBlock.Attributes.Add("onlick","<a href=""#Create_Block""></a>")
        'but it's not working
End Sub
0
 
orbulatCommented:
see if this works.
 
lnkCreateBlock.Attributes.Add("onlick","location.href='#Create_Block';return false;")
0
 
orbulatCommented:
you have to "return false" for the button, otherwise the page will be refreshed if u click that linkbutton
0
 
appariCommented:
try this

Sub lnkCreateBlock (s as obect, e as eventargs)
        CreateBlock(intNumBlock)
        Page.RegisterStartupScript("ShowBlock", "location.href='#Create_Block';")
        'I tried to add something like
        'lnkCreateBlock.Attributes.Add("onlick","<a href=""#Create_Block""></a>")
        'but it's not working
End Sub
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.