2016-06-09 41 views
4

我在顯示引導模式時單擊超鏈接。除了超鏈接,還有一個標籤,其中一些文本是動態打印的。從標籤文本中設置引導模式中的文本框的值

我正在使用jquery在Bootstrap Modal中的Textbox中打印該特定標籤的文本。

文本檢索得很好,但我無法取得成功顯示此文本是bootstrap Modal Textbox。

這裏是我的jQuery代碼:

<script> 
    $(function() { 
     $(".edit").click(function() {  
      var tr = $(this).parent().parent(); 
      var tdRecords = $(tr).children(); 
      var CurrValue = $(tdRecords[0]).text(); 
      var NewValue = $(tdRecords[1]).text(); 
      alert(CurrValue); //alert is showing the value fine 
      $("#Curr_Val").val(CurrValue); //not working 
      $('#myModal').modal('show'); 
     }); 
    }); 
</script> 

這是我的模態代碼:

<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 

      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
       <h4 class="modal-title" id="myModalLabel">Edit Information</h4> 
      </div> 
      <div class="modal-body"> 
       <div class="row"> 
        <div class="col-md-3"> 
         Current Value : 
        </div> 
        <div class="col-md-6"> 
         <asp:TextBox CssClass="txtstyle" runat="server" ID="Curr_Val"></asp:TextBox> 
        </div> 
       </div> 
       <div class="row"> 
        <div class="col-md-3"> 
         New Value : 
        </div> 
        <div class="col-md-6"> 
         <asp:TextBox CssClass="txtstyle" runat="server" ID="New_Val"></asp:TextBox> 
        </div> 
       </div> 
      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-primary">Save Changes</button> 
       <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> 
      </div> 

     </div> 
    </div> 
</div> 

值越來越印在警示很精細,但它不是在文本框得到打印。

有人請幫我一下,我錯過了什麼。

在此先感謝

+0

考慮添加動態呈現的html代碼,即從瀏覽器呈現的html。 – shramee

+0

DId您嘗試硬編碼值進行測試 - $(「#Curr_Val」)。val(「10」);因爲語法看起來不錯。而且如果你可以共享開發者控制檯的任何錯誤將是偉大的 –

+0

@NagaSaiA是我試過$(「#Curr_Val」)。val(「10」);但仍然不起作用 –

回答

4

使用jquery方式訪問asp網絡控件的問題。您需要將其更改爲$('#<%= Curr_Val.ClientID %>').val(CurrValue);

+1

好的,謝謝你...它爲我工作: ) –

+1

自從昨天我對此感到困惑..但你解決了它...我會給你一個贊成票(y)非常感謝你 –

+0

@AlinaAnjum無後顧之憂,樂於幫助解決它:) – Roman