what is this error while login? [Resolved]

Posted by Oswaldlily under JavaScript on 3/5/2013 | Points: 10 | Views : 1162 | Status : [Member] | Replies : 7
I have used this in design page....

<script language="javascript" type="text/javascript">
function validate() {
if (document.getElementById('<%=txtUserId.ClientId %>').value == "") {
alert('Username is Mandtory');
return false;
}
if (document.getElementById('<%=txtPassword.ClientId%>').value == "") {
alert('Password is mandatory');
return false;
}
}
</script>


what is this error?
'System.Web.UI.WebControls.TextBox' does not contain a definition for
'ClientId' and no extension method 'ClientId' accepting a first argument
of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing
a using directive or an assembly reference?)




Responses

Posted by: Santhi on: 3/5/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi

I think ClientID is case sensitive.
Try this.

 (document.getElementById('<%=txtUserId.ClientID %>').value == "")


Thanks & Regards,
Santhi .V

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

Posted by: Pavanandey on: 3/6/2013 [Member] Bronze | Points: 25

Up
0
Down
Check the textbox ids given in the script are correct

Thanks
Pavan Kumar
Mark Answer if this fits the need

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

Posted by: Pavanandey on: 3/6/2013 [Member] Bronze | Points: 25

Up
0
Down
document.getElementById('ContentPlaceHolder1_txtCategory').value == "" can also be used

Thanks
Pavan Kumar
Mark Answer if this fits the need

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

Posted by: Ankitsrist on: 3/6/2013 [Member] Starter | Points: 25

Up
0
Down
it is incorrect <%=txtUserId.ClientId %>, ID should be in uppercase it is case sensitive, write this <%=txtUserId.ClientID %>

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

Posted by: Pavanandey on: 3/6/2013 [Member] Bronze | Points: 25

Up
0
Down
@Ankitsrist

It depends up how he names the textbox

Thanks
Pavan Kumar
Mark Answer if this fits the need

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

Posted by: Jayakumars on: 3/6/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
change This Code

<script language="javascript" type="text/javascript">
function validate() {
if (document.getElementById('<%= txtUserId.ClientID %>').value == "") {
alert('Username is Mandtory');
return false;
}
if (document.getElementById('<%= txtPassword.ClientID %>').value == "") {
alert('Password is mandatory');
return false;
}
}
</script>

Mark as Answer if its helpful to you

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

Posted by: Karthikreddy on: 3/6/2013 [Member] Starter | Points: 25

Up
0
Down
ClientID 'D' is caps

k@rth!k
karthikreddy08a50@gmail.com

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

Login to post response