Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

client side to server side 1

Status
Not open for further replies.

mthrawn

Programmer
Aug 17, 2000
42
GB
Is it possible to call client side functions from the server side (or vice versa), and how do I carry a client side variable to the server side (or vice versa)? [sig]<p>Matt<br><a href=mailto:matt@tubedale.co.uk>matt@tubedale.co.uk</a><br><a href= Solutions</a><br>I'm a mathematician/ computer programmer. My main interests lie in decision mathematics and web development although I am thoroughly capable in most areas of maths as well as many other forms of software development.[/sig]
 
I think from what I have seen in other posts that the quick answer is no for the ability to call functions from one side to the other.

For taking server side variables to the client side I would say if you have a javascript function that contains something like

variable2=<%=serverVariable%>

you achieve that transfer of the server variable value to the client side script. The other direction I do not know if it is possible, someone with more knowledge in the area might give you a better idea of that possibility. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
There is a technology (from Microsoft) called remote scripting that allows you to call functions on the server from a client script. It's not used in many sites, and I confess I haven't tried it myself, but it might be worth looking into if you need this type of functionality. [sig]<p>nick bulka<br><a href=mailto: > </a><br>[/sig]
 
I've never gotten server-side stuff to run without reloading, but you can easily pass data from client to server page, but you've got to make all the pages ASP (obviously) and you've got to either use forms (bulky and annoying) or querystrings (insecure for high-profile data). Examples:

Querystring:
Code:
<SCRIPT lang=javascript>
data = 5;
function LoadNextPage()
{
  Navigate(&quot;mypage.asp?data=&quot; + data);
}
</SCRIPT>

<INPUT type=&quot;button&quot; value=&quot;Goto next page&quot; onclick=&quot;javascript:LoadNextPage();&quot;>

Forms:
Code:
<SCRIPT lang=vbscript>
data = 5
sub LoadNextPage()
  form1.txtdata.value = data
  form1.submit
end sub
</SCRIPT>

<FORM action=&quot;mypage.asp&quot; name=&quot;form1&quot; id=&quot;form1&quot;>

<INPUT type=&quot;button&quot; value=&quot;Goto next page&quot; onclick=&quot;LoadNextPage&quot;>
<INPUT type=&quot;textbox&quot; id=&quot;txtdata&quot; name=&quot;txtdata&quot; style=&quot;visibility: hidden; height: 1px; width: 1px&quot;>

</FORM>

Sorry if something's a little messed up, I just made this all up on the spot. But you should get the idea. The button in the first one just appends the data onto the querystring, and the second one actually includes it in the Request.Form data.



Happy Coding!
~BenDilts( void ); [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top