如何将焦点设置为webForm [英] How to set focus to the webForm

查看:74
本文介绍了如何将焦点设置为webForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  else   if (answer   TextAnswer)
{
.Sourcecode.AppendLine( \t\t\t\t< textarea id =' + id + 'name =' + id + 'value =''style ='position:absolute;
+ top: + top + px; left: + left + px; height: + height + px; width: + width + px;
+ visibility:hidden; z-index:2; resize:none;'>< / textarea>);



这行代码在我的网络表单上创建文本框控件,但问题在那里是没有焦点设置它,我想设置焦点如何做到这一点???

这行代码完全正常我的意思是当我点击我的网络表单它创建一个控件,现在当我点击它,它创建一个控件来写东西,然后我必须再次点击它,所以我只是想当我点击焦点应该在那里。怎么做??????

解决方案

可以使用这样的简单JavaScript代码



  document  .getElementById(  yourTextBoxId)。focus(); 


else if (answer is TextAnswer)
                            {
                                this.Sourcecode.AppendLine("\t\t\t\t<textarea id='" + id + "' name='" + id + "' value='' style='position: absolute; "
                                                         + "top: " + top + "px; left: " + left + "px; height: " + height + "px; width: " + width + "px; "
                                                         + "visibility:hidden; z-index: 2; resize: none;'></textarea>");


this line of code creates textbox control on my web form but the Problem is there is no focus set on it and i want to set focus How to do this???
This line of code works perfectly fine i mean when i click on my web form it crates a control , Now when i click on it, it creates a control to write something then i have to click on it again , so i just want that when i click focus should be there.How to do it??????

解决方案

Can use simple JavaScript code like this

document.getElementById("yourTextBoxId").focus();


这篇关于如何将焦点设置为webForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆