Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 让ASP.NET repeater设置一个动态名称_Javascript_Asp.net - Fatal编程技术网

Javascript 让ASP.NET repeater设置一个动态名称

Javascript 让ASP.NET repeater设置一个动态名称,javascript,asp.net,Javascript,Asp.net,Im使用javascript启用禁用文本框,并根据选中的radiobutton计算价格 我的问题是,我使用radiobutton的groupname来查找正确的文本框,并在计算中使用它的值。当repeater从MyItemTemplate创建代码时,它不会使用supllied参数来创建名称 项目标签中的我的名字是: 名称=“” 它创建的名称是name=“Repeater1$ctl02$textbox”以及我提供的名称标记。 对于单选按钮,它们的名称变为 中继器1$ctl01$sverigemot

Im使用javascript启用禁用文本框,并根据选中的radiobutton计算价格

我的问题是,我使用radiobutton的groupname来查找正确的文本框,并在计算中使用它的值。当repeater从MyItemTemplate创建代码时,它不会使用supllied参数来创建名称

项目标签中的我的名字是: 名称=“” 它创建的名称是name=“Repeater1$ctl02$textbox”以及我提供的名称标记。 对于单选按钮,它们的名称变为 中继器1$ctl01$sverigemotrasism 不公正 sverigemotrasism 有没有办法阻止它创建名称。。。或者我该如何避免这种情况?

这是我的项目模板

    <ItemTemplate>
    <asp:RadioButton id="RadioButton1" runat="server" GroupName='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' value="50" Text="Fri tillgång" onclick="calculatePrice();disableTB(this.name);"  />
    <br />
    <asp:RadioButton id="RadioButton2" runat="server" GroupName='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>' 
        Text="En artikel om dagen(30/mån)" value="25" onclick="calculatePrice();disableTB(this.name);" />
         <br />
    <asp:RadioButton id="RadioButton3" runat="server" GroupName='<%# DataBinder.Eval(Container.DataItem, "idtag_domain")%>'  value="0"
        Text="Skriv antalet artiklar" onclick="enableTB(this.name, this.checked)" />
         <br />
    <asp:TextBox ID="textbox" runat="server"  name='<%# DataBinder.Eval(Container.DataItem, "idtag_domain") %>' Enabled="false" Width="106px" 
        onkeyup="calculatePrice()" style="background-color:#eeeeee" ></asp:TextBox>
    </ItemTemplate>
不幸的是,这就是我的源代码在中继器创建了所有内容之后的样子。。。 中继器数据

    <table>  

     <input id="Repeater1_RadioButton1_0" type="radio" name="Repeater1$ctl01$sverigemotrasism" value="50" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton1_0">Fri tillgång</label>
     <br />
    <input id="Repeater1_RadioButton2_0" type="radio" name="Repeater1$ctl01$sverigemotrasism" value="25" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton2_0">En artikel om dagen(30/mån)</label>
         <br />
    <input id="Repeater1_RadioButton3_0" type="radio" name="Repeater1$ctl01$sverigemotrasism" value="0" onclick="enableTB(this.name, this.checked);" /><label for="Repeater1_RadioButton3_0">Skriv antalet artiklar</label>
         <br />
    <input name="Repeater1$ctl01$textbox" type="text" id="Repeater1_textbox_0" disabled="disabled" class="aspNetDisabled" onkeyup="calculatePrice()" name="sverigemotrasism" style="width:106px;background-color:#eeeeee" />



    <tr>
    <td>




    </td>
    </tr>

     <input id="Repeater1_RadioButton1_1" type="radio" name="Repeater1$ctl02$handlaihop" value="50" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton1_1">Fri tillgång</label>
     <br />
    <input id="Repeater1_RadioButton2_1" type="radio" name="Repeater1$ctl02$handlaihop" value="25" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton2_1">En artikel om dagen(30/mån)</label>
         <br />
    <input id="Repeater1_RadioButton3_1" type="radio" name="Repeater1$ctl02$handlaihop" value="0" onclick="enableTB(this.name, this.checked);" /><label for="Repeater1_RadioButton3_1">Skriv antalet artiklar</label>
         <br />
    <input name="Repeater1$ctl02$textbox" type="text" id="Repeater1_textbox_1" disabled="disabled" class="aspNetDisabled" onkeyup="calculatePrice()" name="handlaihop" style="width:106px;background-color:#eeeeee" />

星期五

阿蒂克尔-奥姆达根(30米/平方米)
斯克里夫·安塔利特·阿蒂克拉尔
星期五
阿蒂克尔-奥姆达根(30米/平方米)
斯克里夫·安塔利特·阿蒂克拉尔

如果您使用的是Framework4.0,则可以使用静态ID作为控件。尝试设置 =静态

但是,有时您不希望ID值按层次嵌套,而是希望ID呈现为您设置为的任何值。要启用此功能,现在可以使用clientdmode=static,在这种情况下,呈现的ID将与在控件的服务器端设置的ID完全相同

如果使用
name
属性,则应该使用
getElementsByName
而不是
getElementById
可能需要设置文本框id而不是名称。考虑到
id
属性对于每个控件必须是唯一的


使用上述建议的设置,我不确定
GroupName
是否是静态的。值得进行测试,如果不起作用,您可以将
CssClass
属性设置为相同的值,并将其用作搜索文本框的键。

这是什么意思:问题是,当中继器松开时,它自己的电源会松脱?我不知道你想说什么。你使用的框架版本可能重复?在在行数据绑定事件中创建收音机按钮。通过这种方式,您可以更好地控制命名。
    <table>  

     <input id="Repeater1_RadioButton1_0" type="radio" name="Repeater1$ctl01$sverigemotrasism" value="50" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton1_0">Fri tillgång</label>
     <br />
    <input id="Repeater1_RadioButton2_0" type="radio" name="Repeater1$ctl01$sverigemotrasism" value="25" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton2_0">En artikel om dagen(30/mån)</label>
         <br />
    <input id="Repeater1_RadioButton3_0" type="radio" name="Repeater1$ctl01$sverigemotrasism" value="0" onclick="enableTB(this.name, this.checked);" /><label for="Repeater1_RadioButton3_0">Skriv antalet artiklar</label>
         <br />
    <input name="Repeater1$ctl01$textbox" type="text" id="Repeater1_textbox_0" disabled="disabled" class="aspNetDisabled" onkeyup="calculatePrice()" name="sverigemotrasism" style="width:106px;background-color:#eeeeee" />



    <tr>
    <td>




    </td>
    </tr>

     <input id="Repeater1_RadioButton1_1" type="radio" name="Repeater1$ctl02$handlaihop" value="50" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton1_1">Fri tillgång</label>
     <br />
    <input id="Repeater1_RadioButton2_1" type="radio" name="Repeater1$ctl02$handlaihop" value="25" onclick="calculatePrice();disableTB(this.name);" /><label for="Repeater1_RadioButton2_1">En artikel om dagen(30/mån)</label>
         <br />
    <input id="Repeater1_RadioButton3_1" type="radio" name="Repeater1$ctl02$handlaihop" value="0" onclick="enableTB(this.name, this.checked);" /><label for="Repeater1_RadioButton3_1">Skriv antalet artiklar</label>
         <br />
    <input name="Repeater1$ctl02$textbox" type="text" id="Repeater1_textbox_1" disabled="disabled" class="aspNetDisabled" onkeyup="calculatePrice()" name="handlaihop" style="width:106px;background-color:#eeeeee" />