Sure, all a server control does is end up producing html for the client, so the client can interact with it as though it has no clue that anything is a server control, to see just view the source of a client side page that was built using server controls, it's just plain ol' html.
Before rendering to the client:
After rendering to the client:Code:<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ClientServer.aspx.vb" Inherits=".ClientServer"%> <html> <head> <title>ClientServer</title> </head> <body> <form id="Form1" method="post" runat="server"> <input type="button" id="ClientSideControl" value="Click Me" onclick="document.Form1.ServerSideControl.value = 'Hello World'"/> <asp:TextBox ID="ServerSideControl" Runat="server"/> </form> </body> </html>
One thing to remember, since there is no state between the client and server(as in javascript will only know what the client knows) you cannot access any special server control properties that would be accessible from the server.Code:<html> <head> <title>ClientServer</title> </head> <body> <form name="Form1" method="post" action="ClientServer.aspx" id="Form1"> <input type="hidden" name="__VIEWSTATE" value="dDwyMTA1NTI4MTE3Ozs+uLuvFCnFMUU8IA+RBGwlVJTVfwM=" /> <input type="button" id="ClientSideControl" value="Click Me" onclick="document.Form1.ServerSideControl.value = 'Hello World'"/> <input name="ServerSideControl" type="text" id="ServerSideControl" /> </form> </body> </html>
For example, the asp:TextBox has a Text property. All that happens is that whatever is set in the Text property of a server control is mapped up to the Value attribute of the input tag that is eventually generated and sent to the client. The clientside code can mess around with the Value attribute using javascript or whatever but it can't do anything with the Text property because only the server(and .Net framework) knows about that one.




Reply With Quote