troubleshooting Question

get variable value from javascript into

Avatar of Codeaddict7423
Codeaddict7423Flag for United States of America asked on
ASP.NETVisual Basic.NETJavaScript
4 Comments1 Solution855 ViewsLast Modified:
 I have a user control form built using Visual Studio 2005 on 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

                e.Total = CDec(Page.Request.Form(totalBox.UniqueID))
                ' 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 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;

The call to this JavaScript is as follows:
      <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>  
I am attempting to duplicate the JavaScript function using VB.NET.  For example, I am trying to write a sub in 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.

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