我需要将HTML文本框值从ContentPlaceHolder2复制到ContentPlaceHolder1上的ASP.NET文本框值。
之所以需要将该asp.net文本框作为ContentPlaceHolder1上存储过程的参数传递(原因是我无法从ContentPlaceHolder2上做到这一点)
我尝试使用Request.Form在代码bedind中执行此操作,但是它不起作用。我认为是因为按钮控件无法访问ContentPlaceHolder2?
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:Button ID="btnCopyIng" runat="server" OnClientClick="Copy()" OnClick="btnCopyIng_OnClick" Text="Copy" />
<asp:TextBox ID="txtIngredientName" runat="server"></asp:TextBox>
<input id="txtIngValue" name="Ing Value" type="text" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
<strong>Ingredient Name: </strong>
<input id="txtIngName_new" type="text" onkeyup="sync()" kendo-text-box="txtIngName" class="k-input k-textbox TextCtrlReqBgImage" name="Ingredinet name" style="width: 350px;" required="required" ng-click="txtIngNameClick()" ng-readonly="ingNameReadOnly" ng-model="selectedIng.Ingredients_Name">
</asp:Content>
后面的代码:
protected void btnCopyIng_OnClick(object sender, EventArgs e)
{
string name = Request.Form["Ingredinet name"].ToString();
txtIngredientName.Text = name;
}
答案 0 :(得分:0)
您可以使用jQuery,您已经创建了对仍然称为复制的OnClientClick函数的引用
function Copy() {
$(‘<%= txtIngredientName.ClientID %>’).val($(‘#txtIngName_new’).val());
}
答案 1 :(得分:0)
我认为这将从后面的代码中解决,从txtIngredientName中获取文本,并为txtIngName_new设置文本:
protected void btnCopyIng_OnClick(object sender, EventArgs e)
{
txtIngName_new.Text = txtIngredientName.Text;
}