Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Scripting / June 2004

Tip: Looking for answers? Try searching our database.

Scripting with a UserControl - how to force a refresh?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julian Hayward - 19 May 2004 09:37 GMT
I have a page which contains a Windows Forms UserControl and several
DIVs within a table. When the mouse is moved over the UserControl,
it ends up calling the following Javascript:

function Map_mouseMoved()
{
  var map = document.getElementById("Map");        // the UserControl
  var msg = document.getElementById("Msgbox");     // a DIV

  if(map != null)
  {
     if (msg != null)
     {
        msg.innerHTML = map.getMessgage();
     }
     window.status = map.getMessage();
  }
}

The getMessage() function returns a string which indicates the mouse
position. What I see when I run it is, when I move the mouse over the
control the text gets written to the status bar every time the mouse
moves by a pixel (OK), but the message DIV only changes when the mouse
enters or leaves the control. I know this function is being called,
so how can I force the browser to refresh the DIV?

The strange thing is, this precise same Javscript worked fine with
a Java applet performing the same task as the UserControl!

Thanks a lot,

Julian
bruce barker - 19 May 2004 17:53 GMT
the div will not update until the next DoEvents loop is called (as the div
update is queued as a windows message). your control could do this after
firing an event.

-- bruce (sqlwork.com)

> I have a page which contains a Windows Forms UserControl and several
> DIVs within a table. When the mouse is moved over the UserControl,
[quoted text clipped - 28 lines]
>
> Julian
Julian Hayward - 27 May 2004 12:15 GMT
I had a try, putting the following in my control:

protected override void OnMouseMove(MouseEventArgs e)
{
   // Internal stuff that updates the control
   foo(e.X, e.Y);
   this.Refresh();
   // Now fire off an event that javascript can pick up.
   if (MapMouseMoved != null)
       MapMouseMoved(this, e);
   // This should get my DIV updated?
   Application.DoEvents();
   // don't forget anything in the baseclass handler.
   base.OnMouseMove(e);
}

Included in my page is:

<SCRIPT LANGUAGE=javascript FOR=Map EVENT=MapMouseMoved>
<!--
Map_mouseMoved();
//-->
</SCRIPT>

and this function gets called - this is what updates the DIV. But no joy,
it still doesn't update while the mouse is moved over the control. Is this
what you meant, or have I missed something?

Thanks,

Julian
bruce barker - 27 May 2004 20:08 GMT
move Application.DoEvents(); to the end of the function (so its called after
the base calless the javascript routine).

-- bruce (sqlwork.com)

> I had a try, putting the following in my control:
>
[quoted text clipped - 27 lines]
>
> Julian
Julian Hayward - 01 Jun 2004 09:18 GMT
> move Application.DoEvents(); to the end of the function (so its called after
> the base calless the javascript routine).

Tried that, sadly it made no difference. I'm really confused now!

Julian

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.