How can you get the X Co-ordinates Y Co-ordinates values during the Mouse Movement?

The X and y co-ordinates during the mouse movement can be obtained by the following codings. <html> <body> <form name='Show'> <b>X Co-Ordinate Value:</b><input type="text" name="X" value="0" size="4"> <br> <b>Y Co-Ordinate Value:</b><input type="text" name="Y" value="0" size="4"> <br> </form> <script language='Javascript'> <!-- // Detect if the browser is IE or not. // If the browser is not IE, we assume that the browser is NS. var IE = document.all?true:false // If NetScape then set up for mouse capture if (!IE) document.captureEvents(Event.MOUSEMOVE) // Set-up to use getMouseXY function onMouseMove document.onmousemove = getMouseXY; // Temporary variables to hold mouse x-y pos.s var tempX = 0 var tempY = 0 // Main function to retrieve mouse x-y pos.s function getMouseXY(e) { if (IE) { // grab the x-y pos.s if browser is IE tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { // grab the x-y pos.s if browser is NS tempX = e.pageX; tempY = e.pageY; } // catch possible negative values in NS4 if (tempX < 0){tempX = 0} if (tempY < 0){tempY = 0} // show the position values in the form named Show // in the text fields named MouseX and MouseY document.Show.X.value = tempX; document.Show.Y.value = tempY; return true; } //--> </script> </body> </html>

How can you make a piece of text get moving along the mouse Movement?

We can make text to move along the mouse using javascript as given below, <html> <head> <style> .spanstyle { position:absolute; visibility:visible; top:-50px; font-size:10pt; font-family:Verdana; font-weight:bold; color:black; } </style> <script> var x,y var step=20 var flag=0 var text='Syncfusion .NET Essentials ' text=text.split('') var xpos=new Array() for (i=0;i<=text.length-1;i++) { xpos[i]=-50 } var ypos=new Array() for (i=0;i<=text.length-1;i++) { ypos[i]=-50 } function handlerMM(e) { x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY flag=1 } function MoveText() { if (flag==1 && document.all) { for (i=text.length-1; i>=1; i--) { xpos[i]=xpos[i-1]+step ypos[i]=ypos[i-1] } xpos[0]=x+step ypos[0]=y for (i=0; i<text.length-1; i++) { var spanvalue=eval('span'+(i)+'.style') spanvalue.posLeft=xpos[i] spanvalue.posTop=ypos[i] } } else if (flag==1 && document.layers) { for (i=text.length-1; i>=1; i--) { xpos[i]=xpos[i-1]+step ypos[i]=ypos[i-1] } xpos[0]=x+step ypos[0]=y for (i=0; i<text.length-1; i++) { var spanvalue=eval('document.span'+i) spanvalue.left=xpos[i] spanvalue.top=ypos[i] } } var timer=setTimeout('MoveText()',30) } </script> </head> <body onload="MoveText()" style="width:100%;overflow-x:hidden;overflow-y:scroll"> <script> for (i=0;i<=text.length-1;i++) { document.write("<span id='span"+i+"' class='spanstyle'>") document.write(text[i]) document.write('</span>') } if (document.layers) { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = handlerMM; </script> </body> </html>

How can you create a check box dynamically in the server control?

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Text; usingSystem.Web; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; namespace WebCustomControl1 { [DefaultProperty('Text')] [ToolboxData('<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>')] public class WebCustomControl1 : WebControl { [Bindable(true)] [Category('Appearance')] [DefaultValue('')] [Localizable(true)] public string Text { get { String s = (String)ViewState['Text']; return ((s == null) ? String.Empty : s); } set { ViewState['Text'] = value; } } protected override void CreateChildControls() { CheckBox blah = new CheckBox(); blah.Text = 'CheckText'; blah.ID = 'CheckValue'; this.Controls.Add(blah); } protected override void RenderContents(HtmlTextWriter writer) { this.EnsureChildControls(); this.RenderChildren(writer); } } }

How can you write events for the server controls?

using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebCustomControl1 { [DefaultProperty("Text")] [ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")] public class WebCustomControl1 : WebControl,IPostBackEventHandler { // Defines the Click event. public event EventHandler Click; //Invoke delegates registered with the Click event. protected virtual void OnClick(EventArgs e) { if (Click != null) { Click(this, e); } } // Define the method of IPostBackEventHandler that raises change events. public void RaisePostBackEvent(string eventArgument) { OnClick(new EventArgs()); } protected override void Render(HtmlTextWriter output) { output.Write("<INPUT TYPE = submit name = " + this.UniqueID + " Value = ’Click Me’ />"); } } }