Detailsview文本框使用javascript在详细信息视图中更改了事件可见字段 [英] Detailsview textbox changed event visible field in details view using javascript

查看:70
本文介绍了Detailsview文本框使用javascript在详细信息视图中更改了事件可见字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在详细视图中有模板字段文本框隐藏/显示其他文本框更改

没有回发因为回发值不是得到其他控制权。





我的代码:

Hi all,

In detailview have template field textbox hide/show when other textbox changes
without postback because postback values is not getting for other control.


my code:

<script type="text/javascript" language="javascript">

       function showhidetextbox(c,f) {

           DetailsView dtlvwActiveList = (DetailsView)Page.Form.FindControl("dtlvwActiveList");

           var text = document.getElementById('<%= dtlvwActiveList.FindControl("txtIIterations").ClientID %>')

           if (text.value == "2") {

               document.getElementById('<%= dtlvwActiveList.FindControl("txtInodayspost").ClientID %>').style.visibility = true;


           }
           else {

                document.getElementById('<%= dtlvwActiveList.FindControl("txtInodayspost").ClientID %>').style.visibility = false;

            }


       }







但是它给错误对象引用没有设置instacne object.plz帮帮我。

i在谷歌尝试但是我没找到解决方案





和可见设计的其他代码false:






but it give error object references is not set instacne object.plz help me.
i try out in google but i did not find out solution


and other code for visible design false:

<asp:TemplateField HeaderText="Iterations (1x – Pre, 2x – Pre & Post, on-going)">

                                                <ItemTemplate>
                                                    <asp:Label ID="lblIterations" runat="server" Text='<%# Bind("Iterations") %>'></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtEIterations"   runat="server" OnTextChanged="txtEIterations_TextChanged" MaxLength="8" Width="6%" Text='<%# Bind("Iterations") %>'></asp:TextBox>&nbsp;x
                                                    <%--<asp:RegularExpressionValidator ID="revEIterations" runat="server" ControlToValidate="txtEIterations"
                                                        ValidationExpression="[0-9\s]*" ErrorMessage="Iterations should be numeric"></asp:RegularExpressionValidator>--%>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="txtIIterations" onchange="showhidetextbox(this,this.form)"   runat="server" MaxLength="8" Width="6%" Text='<%# Bind("Iterations") %>'></asp:TextBox>&nbsp;x
                                                   <%-- <asp:RegularExpressionValidator ValidationGroup="InsertGroup" ID="revIIterations" runat="server" ControlToValidate="txtIIterations"
                                                        ValidationExpression="[0-9\s]*" ErrorMessage="Iterations should be numeric"></asp:RegularExpressionValidator>--%>
                                                </InsertItemTemplate>
                                                <ItemStyle CssClass="DetailsViewItemStyle" />
                                            </asp:TemplateField>


<pre lang="xml">&lt;asp:TemplateField HeaderText=&quot;No.of the days for 2x post&quot; Visible=&quot;false&quot;&gt;
                                            &lt;ItemTemplate&gt;
                                             &lt;asp:Label ID=&quot;lblnodayspost&quot; runat=&quot;server&quot; Text=&#39;&lt;%#Bind(&quot;NoOfDays2xPost&quot;) %&gt;&#39;&gt;&lt;/asp:Label&gt;
                                              &lt;/ItemTemplate&gt;

                                            &lt;EditItemTemplate&gt;
                                             &lt;asp:TextBox ID=&quot;txtEnodayspost&quot;  runat=&quot;server&quot; MaxLength=&quot;8&quot; Width=&quot;6%&quot; Text=&#39;&lt;%# Bind(&quot;NoOfDays2xPost&quot;) %&gt;&#39;&gt;&lt;/asp:TextBox&gt;&amp;nbsp;
                                                &lt;asp:RangeValidator ID=&quot;YourERangeValidator&quot; runat=&quot;server&quot;
                                                ControlToValidate=&quot;txtEnodayspost&quot;
                                                ErrorMessage=&quot;Please enter a number between 0-99&quot;
                                                Type=&quot;Integer&quot;
                                                MinimumValue=&quot;0&quot;
                                                MaximumValue=&quot;99&quot;&gt;&lt;/asp:RangeValidator&gt;

                                              &lt;asp:RequiredFieldValidator ID=&quot;rfvtxtEnodayspost&quot; runat=&quot;server&quot; ControlToValidate=&quot;txtEnodayspost&quot;
                                                        Text=&quot;&quot; ErrorMessage=&quot;No of days 2x post is required&quot; Display=&quot;Dynamic&quot;&gt;&lt;/asp:RequiredFieldValidator&gt;
                                            &lt;/EditItemTemplate&gt;



                                            &lt;InsertItemTemplate&gt;
                                              &lt;asp:TextBox ID=&quot;txtInodayspost&quot;   runat=&quot;server&quot; MaxLength=&quot;8&quot; Width=&quot;6%&quot; Text=&#39;&lt;%# Bind(&quot;NoOfDays2xPost&quot;) %&gt;&#39;&gt;&lt;/asp:TextBox&gt;&amp;nbsp;

                                             &lt;asp:RangeValidator ID=&quot;YourIRangeValidator&quot; runat=&quot;server&quot;
                                                ControlToValidate=&quot;txtInodayspost&quot;
                                                ErrorMessage=&quot;Please enter a number between 0-99&quot;
                                                Type=&quot;Integer&quot;
                                                MinimumValue=&quot;0&quot;
                                                MaximumValue=&quot;99&quot; &gt;&lt;/asp:RangeValidator&gt;
                                                 &lt;asp:RequiredFieldValidator ID=&quot;rfvtxtInodayspost&quot; runat=&quot;server&quot; ControlToValidate=&quot;txtInodayspost&quot;
                                                        Text=&quot;&quot; ErrorMessage=&quot;No of days 2x post is required&quot; Display=&quot;Dynamic&quot;&gt;&lt;/asp:RequiredFieldValidator&gt;

                                            &lt;/InsertItemTemplate&gt;



                                              &lt;ItemStyle CssClass=&quot;DetailsViewItemStyle&quot; /&gt;
                                            &lt;/asp:TemplateField&gt;</pre>

推荐答案

这篇关于Detailsview文本框使用javascript在详细信息视图中更改了事件可见字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆