troubleshooting Question

get variable value from javascript into asp.net

Avatar of Codeaddict7423
Codeaddict7423Flag for United States of America asked on
ASP.NETVisual Basic.NETJavaScript
4 Comments1 Solution855 ViewsLast Modified:
Hello,
 I have a user control form built using Visual Studio 2005 on vb.net with a JavaScript call to calculate total.
Below, please find my code:
-----------
 Protected Sub RSVPForm1_CalculateTotalEvent(ByVal e As HGACServerControls.CalculateTotalEventArgs)
        If (IsPostBack) Then
           
            Dim totalBox As HiddenField
                
           
            'find the control
            totalBox = RSVPForm1.FindControl("hdnTotal")
                       
            'Lets go ahead and throw an exception if the we could not find our total
            'If (totalBox Is Nothing) Then
            'Throw New Exception("Could not get total")
            'End If

            Try
                e.Total = CDec(Page.Request.Form(totalBox.UniqueID))
            Catch
                ' If Conversion does not work set to zero
                e.Total = New Decimal(0)
            End Try
                   
        End If
    End Sub
   
    Protected Sub RSVPForm1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim hdnTotal As HiddenField
       
        hdnTotal = RSVPForm1.FindControl("hdnTotal")
       
       
       
        If Not (hdnTotal Is Nothing) Then
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "hdnTotalIdScript", "var hdnTotalId = '" + hdnTotal.ClientID + "';", True)
        End If
       
       
    End Sub
</script>
<script language="JavaScript" type="text/javascript">

function RegTotal()
{
form = document.forms[0];


if ((form.Total.value == "0") || (form.Total.value.length == 0))
      {      
      alert("Please enter a sponsorship amount before submitting the form.");
      }

var obj = document.getElementById(hdnTotalId);


obj.value = form.Total.value;

}
</script>
-----------
The call to this JavaScript is as follows:
----------
<tr>
     
      <td style="background-color:#FFFFBF"><strong><span style="color:Crimson">Amount sponsor: $ </span></strong></td>
      <td style="background-color:#FFFFBF"><INPUT TYPE=TEXT NAME="Total" SIZE=12 onChange="RegTotal();" value="0" style="background-color:#FFFFBF;font-weight:bold;" />      
      <asp:HiddenField ID="hdnTotal"  runat="server"/></td>  
   
</tr>
-------
I am attempting to duplicate the JavaScript function using VB.NET.  For example, I am trying to write a sub in vb.net specifically to capture the call this code:
-----------
var obj = document.getElementById(hdnTotalId);
obj.value = form.Total.value;
-------
of interest, is the call to "hdnTotalID".

ANY help would be greatly appreciated.

ASKER CERTIFIED SOLUTION
Miguel Oz
Senior Software Engineer
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros