Dynamically created controls are a pain in the arse to reference on postback
in ASP.NET, so it's generally easier to just create one on the serverside,
and then check it on postback.
There are plenty of hacks, like duplicating the prefix on the ID and name of
the control, which forces .NET to assume that it was created at the server
side, but if there any real form of control validation (.NET is very big on
security), this breaks it, as the control wasn't created when the page was
delivered to the client.
Christian Bach wrote:
>
> Append a hidden input element to the form.
> $("your single form id").append('<input type="hidden"
> name="myserversecret" id="myserversecret"/>');
>
> then append a different value depending on which textarea the user hit
> the "enter" button.
>
> $("#myserversecret").val("I hit enter in the second textearea");
>
> /c
>
>
> Dan Atkinson wrote:
>> Yes, that's a good idea!
>>
>> How/what do you think I could pass something to the server though, to
>> make
>> it know which button was clicked? It doesn't seem to matter which button
>> I
>> run the click function on, it's always the same (first) one.
>>
>>
>> Christian Bach wrote:
>>> I see, i guess i have to pay more attention :)
>>>
>>> OK, how about this.
>>>
>>> var submitType = false;
>>> $("your single form id").submit(function() {
>>> if(submitType == "type1") {
>>> // do something
>>> } else if(submitType == "type2") {
>>> // do something
>>> } else {
>>> return false;
>>> }
>>> });
>>> $("#ctl00_contentPlc_txtPassword").keydown(function(e){
>>> // set type
>>> submitType = "type1";
>>> // fire submit.
>>> $("your single form id").submit();
>>> });
>>> $("#ctl00_contentPlc_txtOtherPassword").keydown(function(e){
>>> // set type
>>> submitType = "type2";
>>> // fire submit.
>>> $("your single form id").submit();
>>> });
>>>
>>> /christian
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/Determine-which-textarea-had-focus-when-%27enter%27-was-pressed.-tf2298484.html#a6387429
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/