我已经向 webpart 添加了一个按钮 - 我想要启用它旁边的禁用文本框的功能。在部署时,我收到一个错误:无法将类型“bool”隐式转换为“字符串”
当我转换为字符串以尝试解决问题 ( JDHFBtn.OnClientClick = Convert.ToString(JDHFTxt.Enabled = true);
) 时,它使文本框始终可编辑。我正在寻找解决问题的方法。请原谅我的无知 - 我是 C# 和 Web 部件的新手,并且在编程方面并不先进。谢谢你。
这是有问题的代码:
sb.Append("</td>");
sb.Append(" </tr>");
sb.Append(" <tr class=\"row2\">");
sb.Append(" <td class=\"rowTextLeft\" width=\"25%\">SPR/JDHF Allotment:</td>");
sb.Append(" <td class = \"rowText\" td width=\"75%\">");
lc3 = new LiteralControl(sb.ToString());
Controls.Add(lc3);
TextBox JDHFTxt = new TextBox();
JDHFTxt .ID = "txtJDHF";
JDHFTxt .Enabled = false;
JDHFTxt .Width = 100;
JDHFTxt .Text = ConvertToFunding(DrACE["SPRAllotment"].ToString());
Controls.Add(JDHFTxt);
sb = new StringBuilder();
lc7 = new LiteralControl();
Controls.Add(lc7);
Button JDHFBtn = new Button();
JDHFBtn.ID = "btnJDHF";
JDHFBtn.CssClass = "plainButton";
JDHFBtn.Text = "Edit";
//JDHFBtn.OnClientClick = JDHFTxt.Enabled = true;
//JDHFBtn.Attributes.Add("OnClick, JDHFTxt.Enabled = true);
JDHFBtn.OnClientClick = Convert.ToString(JDHFTxt.Enabled = true);
Controls.Add(JDHFBtn);
sb = new StringBuilder();
sb.Append("</td>");
sb.Append(" </tr>");