本文介绍了在aspx页面中回发后如何设置对Activex控件的关注?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用客户端脚本将焦点放在回发事件之后的特定控件上,它对HTML控件正常工作,但对我项目中的Activex控件不起作用,请提出一些解决方案.这是代码



Im using client side scripting for setting focus on particular control after postback event, Its working properly for HTML controls but its not working for activex control that im having in my project, please suggest some solution. here is code



public static void SetFocus(Control control)
{
    StringBuilder sb = new StringBuilder();
 
    sb.Append("\r\n<script language=''JavaScript''>\r\n");
    sb.Append("<!--\r\n"); 
    sb.Append("function SetFocus()\r\n"); 
    sb.Append("{\r\n"); 
    sb.Append("\tdocument.");
 
    Control p = control.Parent;
    while (!(p is System.Web.UI.HtmlControls.HtmlForm)) p = p.Parent; 
 
    sb.Append(p.ClientID);
    sb.Append("[''"); 
    sb.Append(control.UniqueID); 
    sb.Append("''].focus();\r\n"); 
    sb.Append("}\r\n"); 
    sb.Append("window.onload = SetFocus;\r\n"); 
    sb.Append("// -->\r\n"); 
    sb.Append("</script>");
 
    control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString());
}

推荐答案


这篇关于在aspx页面中回发后如何设置对Activex控件的关注?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:38