Unable to access a text field (text box)

Posted by Laghaterohan under JavaScript on 5/10/2011 | Points: 10 | Views : 1332 | Status : [Member] | Replies : 3
Hello,

Following is my code block:
<asp:TemplateField HeaderText="Pay Order No.">
<ItemTemplate>
<asp:TextBox ID="txtPay" runat="server"
Width="100px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>


My Javascript Function:
function VerifyPayOrder() {
var payAmount = document.getElementById('<%=txtPay.ClientID%>').val; // I GET ERROR HERE AS txtPay can not be found on compile of the form...
}
return Ok;
}

Please help me to solve the ERROR...

Best Regards,
Rohan Laghate



Responses

Posted by: Ndebata on: 5/10/2011 [Member] Starter | Points: 25

Up
0
Down
Hi

As you writing your control in side gridview , it will generate a number of control based on the row count, so clientid will be changed on rendering :)
. if you want to do any thing on this control try to use RowDatabound event of the grid and use find control to find the desired control to do any operation on it.

Thanks,
Debata

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 5/10/2011 [Member] Starter | Points: 25

Up
0
Down
Client side method ?

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srinivas673 on: 5/12/2011 [Member] Starter | Points: 25

Up
0
Down
if ($('input[id$=txtFooterPromoCode]').val() == '') {
alertmessage($('input[id$=txtFooterPromoCode]'), $("#imgCode"));
str = "- Promocode <br/>";
}
else {
removealertmessage($('input[id$=txtFooterPromoCode]'), $("#imgCode"));
}

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response