|
-
Feb 28th, 2007, 06:40 AM
#1
Thread Starter
Addicted Member
[2005] how to get document.getElementById for a server control in WebUserControl?
Hi,
Am designing a chat application. It uses IFRAME to display the conversation between users. It is a web user control. I wish to scroll programmatically the content of IFRAME at last on every send button click event. I designed the entire control as a web user control. Any solution to move the content. If you have any better solution it will be appreciated.
I tried the following,
Code:
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyScript", "var x = document.getElementById('" + Me.chatFrame.ID() + "'); alert(x); x.scrolltop=x.scrollHeight", True)
But the above coding is working but, It displays x is null. so the next statement is not worked. So the scrolling is not happening.
I tried Me.chatFrame.CleintID instead of me.chatFrame.ID(). but it is not working.
regards,
Senthil
God has been pleased to place as a king or cobbler do the work sincerely
-
Feb 28th, 2007, 06:51 AM
#2
Re: [2005] how to get document.getElementById for a server control in WebUserControl?
Try using clientID instead of ID especially as your control is in a user control you can't always tell what it's ClientID is going to be.
Code:
Me.chatFrame.ClientID()
-
Feb 28th, 2007, 07:00 AM
#3
Re: [2005] how to get document.getElementById for a server control in WebUserControl?
He said clientID isn't working. Then again, isn't x.scrolltop supposed to be x.scrollTop?
-
Feb 28th, 2007, 07:08 AM
#4
Re: [2005] how to get document.getElementById for a server control in WebUserControl?
 Originally Posted by mendhak
He said clientID isn't working. Then again, isn't x.scrolltop supposed to be x.scrollTop?
Oops 
Note to self: I must read questions in their entirety.
-
Feb 28th, 2007, 07:29 AM
#5
Thread Starter
Addicted Member
Re: [2005] how to get document.getElementById for a server control in WebUserControl?
It is not get the element by id. It shows 'Null'. First of all, the alert should display "object" not as "null". Then only it will take effect for scrolltop=scrollheight
God has been pleased to place as a king or cobbler do the work sincerely
-
Mar 3rd, 2007, 10:30 PM
#6
Fanatic Member
Re: [2005] how to get document.getElementById for a server control in WebUserControl?
you are missing the semi-colon at the end of the script block:
should be:
x.scrolltop=x.scrollHeight; // <-- missing semi-colon
-
Mar 3rd, 2007, 10:35 PM
#7
Fanatic Member
Re: [2005] how to get document.getElementById for a server control in WebUserControl?
I think it should be like this
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyScript", "function doit() {var x = document.getElementById(" + Me.chatFrame.ClientID + "); alert(x); x.scrollTop=x.scrollHeight;}", True)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|