开发者

scroll position on Ajax's Timer OnTick event

开发者 https://www.devze.com 2023-04-02 07:44 出处:网络
Inside the one of contentPlaceHolder of the masterpage I\'m using Iframe. And In Iframe suppose, IfrmPage.aspx I\'m using update panel where timer control is updating the page for each certain duratio

Inside the one of contentPlaceHolder of the masterpage I'm using Iframe. And In Iframe suppose, IfrmPage.aspx I'm using update panel where timer control is updating the page for each certain duration.

So, what I'm trying to do is settng the focus on textbox after OnTick event. I'm usin开发者_开发技巧g following line:

ScriptManager1.SetFocus(this.txtMessage.ClientID);

This works correctly. However, Main page or I should say masterpage's scrollbar changes their position which is annoying.

Please share your valuable experience.

thanks.


Have you tried using MaintainScrollPositionOnPostback on the page declaration of IfrmPage.aspx?


After seaching on the google I found the answer.

Now I'm setting the focus to txtMessage(textbox) using javascript and remove this code: ScriptManager1.SetFocus(this.txtMessage.ClientID); final answer is here:

<script type="text/javascript">
     var prm = Sys.WebForms.PageRequestManager.getInstance();
     prm.add_pageLoaded(pageLoaded);
     function pageLoaded(sender, args) {
         if (args.get_panelsUpdated().length > 0) {
             $get('txtMessage').focus();
         }
     }
</script>
0

精彩评论

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