1 Replies - 2409 Views - Last Post: 21 April 2013 - 05:52 AM Rate Topic: -----

#1 kuu  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 25-November 10

Using jquery and repeater together with ClientID

Posted 21 April 2013 - 05:15 AM

Hi everyone;

I examine lots of blogs answers about my question also I found some solution from this sites and I tried all of them. But I don't know why is it? These solutions are not fix my problem I get errors always.
Finally, I found a solution that I recognize that is true, because in many place this solution is accepted. But this cannot solve my problem again.

$("#<%=plusBttn.ClientID%>")


I get this error when I tried this solution : plusBttn does not exist in the current context.

I use predictable mode for client mode for my buttons and textbox. Simply, I want to change quantity , which shown in a textbox(QuantityTxtbx), with control my buttons (minusBttn for decrease the value of quantityTxtbx value and plusBttn similarly use for increase the value)

Actually my problem is in the find my controls by using ClientID in jscript.

Codes the shown above are all in the Repeater,ItemTemplate:

My jscript code in asp.net page:

$(document).ready(function () {
                                     
       $("#<%=plusBttn.ClientID%>").click(function () {
          var value = parseInt($("input[id$='QuantityTxtbx']").val());
          value = value + 1;
          $("input[id$='QuantityTxtbx']").val(value);
          });
        
         $("input[id$='#minusBttn_']").click(function () {
                    var value = parseInt($("input[id$='QuantityTxtbx']").val());
                                        if (value > 1)
                                            value = value - 1;
                                        $("input[id$='QuantityTxtbx']").val(value);
                                    });
                                });


And my controls ;



<asp:Button ID="minusBttn" runat="server" Text="-"  ClientIDMode="Predictable"/> 
    <asp:TextBox ID="QuantityTxtbx" runat="server" Text='<%#Eval("Quantity") %>' Enabled="False" EnableTheming="False" EnableViewState="False" Height="16px" Width="16px" Wrap="False"ClientIDMode="Predictable">1</asp:TextBox>
    <asp:Button ID="plusBttn" runat="server" Text="+" ClientIDMode="Predictable" />


Is This A Good Question/Topic? 0
  • +

Replies To: Using jquery and repeater together with ClientID

#2 kuu  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 25-November 10

Re: Using jquery and repeater together with ClientID

Posted 21 April 2013 - 05:52 AM

And Here is the my browser side code:

 <script type="text/jscript">
    
                            $(document).ready(function () {
                                var plusBttn = $("input[id$='minusBttn']");
                                $("input[id$='#minusBttn_']").click(function () {
                                    var value = parseInt($("input[id$='QuantityTxtbx']").val());
                                    value = value + 1;
                                    $("input[id$='QuantityTxtbx']").val(value);
    
                                });
                                $("input[id$='#minusBttn_']").click(function () {
                                    var value = parseInt($("input[id$='QuantityTxtbx']").val());
                                    if (value > 1)
                                        value = value - 1;
                                    $("input[id$='QuantityTxtbx']").val(value);
                                });
                            });
                            
                        </script>
                        
                        <input type="submit" name="ctl00$ContentPlaceHolder1$Repeater1$ctl01$minusBttn" value="-" id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_minusBttn_0" /> 
                        
                       
                        <input name="ctl00$ContentPlaceHolder1$Repeater1$ctl01$QuantityTxtbx" type="text" value="2" id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_QuantityTxtbx_0" disabled="disabled" style="height:16px;width:16px;" />
                        <input type="submit" name="ctl00$ContentPlaceHolder1$Repeater1$ctl01$plusBttn" value="+" id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_plusBttn_0" />

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1