
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!