繁体   English   中英

带有文本框的JavaScript和html代码

[英]Javascript and html code with Text Box

我必须在button.click事件中插入文本框。 为此,我一直使用此代码在ASPX.VB文件中实现它。

下面的代码用于修正所附的屏幕截图,该屏幕截图显示了删除按钮旁边的文本框。

问题:

示例:如果我们在ASPX页面中插入任何简单的文本框,则可以获取该文本框ID,并可以在aspx.vb文件中使用它。 以相同的方式,我想通过拥有文本框ID来使用以下代码。 怎么样?

我需要如何使用此文本boxId(id =“” txtExperimentalStressdays“”)并将用户输入的数据保存到数据库中。

我只需要执行以下操作:调用方法插入文本框数据,调用textboxdatainsertmethod(txtExperimentalStressdays.text)

问题是,如上一行所述,此文本框代码将不起作用,因为它在“”引号中。

在此处输入图片说明

testTypeNode.Text = testTypeNode.Text & "" & _  
" <img src=""../images/delete_16x.ico""" & _  
" style=""text-align:bottom; cursor:pointer;"" alt=""Delete TestType""" & _  
" title=""Delete TestType"" onclick=""javascript:if(confirm('Are you sure you want to delete? Any running tests will be aborted!'))" & _  
" {" & ClientScript.GetPostBackEventReference(btnDeleteTestType, "" & sequenceNode.Value.ToString & _  
WordSeparationChar & testTypeNode.Value.ToString & "") & ";};"" />" & _  
"<inputtype= ""text""id= ""txtExperimentalStressdays""name=""ExperimentalStressdays""size=""4"" title=""Pleaseenter the Experimental Stressdays"" javascript:onfocusdown(/>"

您可以尝试在代码中使用“ \\”作为转义字符。

谢谢

可能要容易得多的方法是继续创建文本框,但是使用javascript更改可见性。 例如,您的文本框可能开始隐藏:

<asp:TextBox ID="txtBox" runat="server" CssClass="1887txt" Text="" Style="display: none;"></asp:TextBox>

然后,按一下按钮的OnClick(只需直接从.ascx或使用* .Attributes.Add(“ onClick”,“ yourfunction”)方法在后面的代码中附加javascript函数即可。您在.ascx中的按钮如下所示:

<asp:Button ID="Button2" runat="server" CssClass="1887lbl" OnClientClick=:firejs(); return false;"
                 Text="Submit" UseSubmitBehavior="false" />

然后你的JavaScript函数

function firejs(){
   var txt = !GetServerControl("input", "txtBox");
   txt.style.display = "none";
}

只是一个主意。 不知道您到底想做什么...

-sf

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM