How Can I Pass Data Between the Server Side and the Client Side VB/JScript 
Author Message
 How Can I Pass Data Between the Server Side and the Client Side VB/JScript

You're making it harder than it has to be.  The typical way is to use a
custom validator control:

http://www.*-*-*.com/
m

As far as passing information from the server side code to the client side
script, can you just stuff it in a hidden form field?

- Scott Swigart
www.3leaf.com
weblog: http://www.*-*-*.com/


Quote:
> Hi!

> I'm working with WebForms on VB.Net, I'm doing the validating process of
the
> data in the client-side, with javascript
> functions before to Insert the data on the SQL Server 2k Database, I
choose
> to do it in the client-side, because I need
> to show a messagebox and to set the foucs on a control on a validation
> exception... now I need to check for duplicate
> records, but the only way to do it that I see, is to do it in the server
> side... but how can I pass the result of this
> validation to the client again?

> my code looks like this:

> On the JavaScript source:

> function validate()
>   {
>     window.document.Form1.txtValid.value = 0;

>     if (window.document.Form1.Text1.value == '')
>       {
>         alert('notify some error');

>         window.document.Form1.Text1.focus();
>         window.document.Form1.Text1.select();
>       }

>     ...

>     //If everything it's ok the only way to comunicate the success of this
> to the vb code, is to asign a value to a hidden
>     //control... do you know a way to avoid this?

>     window.document.Form1.txtValid.value = 1;
>   }

> On the VB Side:

> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Handles MyBase.Load
>   ...

>   btnAccept.Attributes.Add("onClick", "validate()")
> End Sub

> Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnNuevoAceptar.Click
>   If (txtValid.Text = "1") Then
>     'I can store the data
>   End If
> End Sub

> so, my questions are:

> 1-) How can I pass data from jscript to vb without using a TextBox?
> 2-) In the validate function how can I know the value of some variable
used
> in vb?
> 3-) Using RegisterStartupScript is a good way to call a script function on
> the load event of the form, but...
>     4-) What If I want to unregister it it's possible? or to change the
> definition of the script?
>     5-) There's a way on Vb to raise a reload event of th webform? or to
> raise any event of the webform on the client side?

> Really Thanks!



Wed, 08 Jun 2005 16:28:37 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. getting server side vbscript array to client side jscript

2. pass server side vbscript to client side javascript

3. how to pass client side values to server side

4. Passing variables from server-side to client-side

5. Passing variables from client-side to server-side

6. Passing a server side var to client side block

7. Passing Server Side Arrays to Client Side Scripts

8. Passing Server side vars to Client side

9. Calling Server Side JScript from Server Side VBScript

10. Accessing Data generated with client-side script from server-side script

11. server-side data into client-side object

12. attached Contact Item on server-side becomes attached Mail Item on client-side

 

 
Powered by phpBB® Forum Software