hi!
i am take3 textboxes, i enter text in first textbox that textbox charcters length is displayed in 2nd textbox
(means i am writing code for send messsages. message is write in first textbox and characters left is displayed in 2nd textbox(max characters is 450).
and if user enter 0 to 150 characters,message send one time. and user enter morethan 150 upto 300 message send 2 times(1 To 150 characters are one message and 151 to remaing characters are another message)
so message count is displayed in 3rd texbox this code is write in javascript. by default 3rd Textbox text is 1.
when i enter some 250 charactes that time message count textbox display "2". it displays.
for practing i am taking one label and button, in that label i display message count text. so i write code like
label1.Text = txtMessageCount.Text;
Every time in label display "1", every time it display default value. if i enter 450 characters that time also it display Messagecount text is "1". i am execute using breakpoint this first execute button code and next go to Javascript code. but my aim is first execute javascript code and next execute button code.
please give a solution. and one more thing i write javascript code in child page and function name is write in master page that is
<body onLoad="TextCount();">
when i am goto other child pages one error occured in run time i.e., Microsoft JScript runtime error: Object expected.
please give solution of these 2 problems.
Thanks
Loading
Amit ChoudharyPosted May 1, 2010, 2:26 AM
Send me your files... i have to check your javascript code..
ajay rajuPosted May 1, 2010, 1:47 AM
i am using it
document.getElementById('<%=txtMessageCount.ClientID%>') ;
but also "Microsoft JScript runtime error: Object expected." error message is displayed
please give a answer.
Thanks.
Amit ChoudharyPosted Apr 30, 2010, 1:49 AM
i think the error you are getting is because of you are using document.getElementById() function and it cud'nt find the control on page.
it happens with server control because their ID's get changes during Asp.net cycle.
so do one thing..
use following syntax:
document.getElementById('<%=txtMessageCount.ClientID%>') ;
Will give you autogenerated client id of servercontrols. it'll solve your error of "Object expected. "
Please mark "Do you like this post" if it helps you.