0

I am calling asp.net button click event through jquery.

$('[id$=btnSaveAsp]').click();

I am sending html data into asp.net hidden field. It is working fine with small amount of data but it is not firing with large amount of data. What should I do???

Community
  • 1
  • 1
Rizwan Qureshi
  • 594
  • 2
  • 8
  • 20

2 Answers2

1

You have to change your code to

$('#'+'<%= aspBtn.ClientID %>').click();

As I see you select you dom element using jquery and it's id. In order to accomplish this you should use the # inside your selector. Also you haven't to use =id$ = inside you selector.

Generally, when you want to select an element using jquery and the id of the element, you have to follow the following pattern:

$('#id')

where id is the id of the element you want to select.

For further documentation on this, please look here.

Christos
  • 53,228
  • 8
  • 76
  • 108
  • what is the difference using "#" – Rizwan Qureshi Apr 22 '14 at 15:55
  • There isn't any difference. Just when you have to select elements by id and using jquery you have to follow this way. I will post a couple of links in order to make it more clear, if it is not. – Christos Apr 22 '14 at 15:56
  • my problem is that it is not firing with large amount of data – Rizwan Qureshi Apr 22 '14 at 15:58
  • @RizwanQureshi if that's your only code, it shouldn't fire even with few data. The reason why I am telling this is that you don't attach the event to the element you want - to the button -, because you have not selected it correctly. It's not a matter of the size of data you have. If that's not clear I could provide you with a link to fiddle to see what I mean. Please just let me know. Thanks – Christos Apr 22 '14 at 16:00
  • Please try to use, what I have posted, $('#'+'<%= aspBtn.ClientID %>').click(); . This will work. If it doesn't, please just let me know -in that case somewhere else should be the problem. But in any case the way you have selected the element is not correct. – Christos Apr 22 '14 at 16:04
1

It is not the problem of click event. It is actually problem of http runtime in asp.net web config file Please add this tags in web.config to resolve this issue.

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="40960" requestValidationMode="2.0"/>
        <pages validateRequest="false"></pages>
    </system.web>
</configuration>
Rizwan Qureshi
  • 594
  • 2
  • 8
  • 20
  • Ok, your request is too big and you have to make this change to your web.config. My questions still remains the same. does the click event works, if you make this change? I mean does this piece of code $('<%=id$ = aspBtn.ClientID %>').click(); works? I still believe it is not. – Christos Apr 23 '14 at 06:23
  • Sory chris, I wrote my code by minor mistake. my click code is $('[id$=btnSaveAsp]').click(); and it is working fine with this changes in web.config – Rizwan Qureshi Apr 23 '14 at 06:37