开发者

how to set focus on control

*ASP.NET VB.NET 2010 ****

Hi, KIndly he开发者_如何学JAVAlp me with this, I have a list of Hyperlink. If I press radio button I want my cursor to focus on one of my hyperlink

I tried to used this but no luck Dim sScript As String = "document.getElementById('" & hlnkQNo.ID & "').focus();" 'Page.RegisterStartupScript("controlFocus", sScript)

I also tried this but the same, the cursor was not focus on my link ScriptManager1.SetFocus(hlnkQNo.ID).

Here is my example of what I want Hyperlink1 Hyperlink2 Hyperlink3 Hyperlink3 Hyperlink4

if the use click the radio button i want to focus on Hyperlink4


Your question is difficult to understand, but generally if you want to focus an element you need to set an event handler on the radio button so that when it's clicked another element receives focus.

    document.getElementById("myRadioButton").click = function(){
        document.getElementById("Hyperlink1").focus();
    };

If your code is being generated server side with VB.NET, then you're going to have to figure out exactly how the snippet above should be rendered.


just to provide an alternative, maybe you might want to consider using jquery to do those kind of things.

and as long as you put runat="server" on your control, you can still retrieve all the value or manipulate them on the server side.

<a href="http:www.yahoo.com">link 1</a>
<a href="http:www.yahoo.com">link 2</a>
<a href="http:www.yahoo.com">link 3</a>
<a href="http:www.yahoo.com">link 4</a>
<br />
<input type="radio" name="radio4" id="radio4" value="4" /> 4<br />

$(document).ready(function(){

    $("#radio4").click(function(){
        $("a:eq(3)").css('color','red');
        $("a:eq(3)").focus();
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜