更新时间:2023-02-16 16:39:57
我想你可能需要在你的作业都字符串的@,并删除斜杠:
I think you might need the @ on both string literals in your assignment, and remove the slashes:
mycontrol.stringparameterforjscript = @"document.getElementById('" + myotherparam + @"').value = 'Hello'";
的修改的
我怎么做的:
在在.aspx:
<asp:Textbox ID="tbTest" runat="server" TextMode="MultiLine" />
在code:
protected void Page_Load(object sender, EventArgs e)
{
string myotherparam = "paramval";
tbTest.Attributes.Add("onfocus", @"document.getElementById('" + myotherparam + @"').value = 'Hello'");
}
结果输出:
<textarea name="tbTest" rows="2" cols="20" id="tbTest" onfocus="document.getElementById('paramval').value = 'Hello'"></textarea>