1

The follow code does not work in IE:

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
    $(function(){
            $(":text[id*=txtPopCEP]").keypress(function(e){
                  var tecla = (e.which) ? e.which : e.keycode;
                  if(tecla == 13)
                  {
                      __doPostBack('ctl00$ContentPlaceHolder1$ImageButton1', '');

                  }
            });
    });
</script>

It doenst call the doPostBack function.But in FF it works...Any ideias?

ImageButton1 code output:

    <input type="image" name="ctl00$ContentPlaceHolder1$ImageButton1" id="ctl00_ContentPlaceHolder1_ImageButton1" src="imagens/btCEP.jpg" style="border-width:0px;" />
5
  • can you paste in the actual HTML output to the client for ImageButton1 ? ~ and you can probably just stick with e.keycode Commented Oct 14, 2010 at 19:15
  • <asp:ImageButton ID="ImageButton1" ImageUrl="imagens/btCEP.jpg" runat="server" OnClick="btnPopCEP_Click" /> Commented Oct 14, 2010 at 19:17
  • @user257234 that is what is written in your source files. can you view the output in the browser? also try it without the e.which stuff Commented Oct 14, 2010 at 19:21
  • hmmm, I don't see a __doPostBack() attached to the HTML, but try just using var tecla = e.keycode; first Commented Oct 14, 2010 at 19:23
  • ive removed e.which,but nothing happened Commented Oct 14, 2010 at 19:27

2 Answers 2

0

Sometimes IE doesn't like the ":text[id*=txtPopCEP]" conditional in JQuery.

I suggest adding: CssClass="txtPopCEP" to the ImageButton...

Then making your conditional $(".txtPopCEP")

Sign up to request clarification or add additional context in comments.

3 Comments

the problem isnt in selector,because its getting correct textbox,the problem is with the __doPostBack function
Another issue could be is that you're using a hard coded ClientId
I would suggest having the code behind populate the JavaScript with a ImageButton1.ClientId
0

__doPostBack dont work directly with image and buttons. Add the onclick through aspx.cs page.
For intance check below code:

script = "javascript:return popUpCalendar(this," + txtEndDate.ClientID + @",'" + DateTime.Today.ToString("MM/dd/yyyy") + @"','" + EstartDate + @"','" + EendDate + @"',  'mm/dd/yyyy',  '__doPostBack(\'" + txtStartDate.ClientID + @"\'),')";
imgEndDate.Attributes.Add("onclick", script);

Hope this will work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.