Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > ASP.NET 4.5 General Discussion
|
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2013, 09:33 AM
Registered User
 
Join Date: May 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Javascripot equivalent for VB.Net Code

Hi,

I am a novoice user in javascript and looking for javascript code equivalent for the below vb.net code written by me. Can anybody show some light on converting this code to Jquery please?


Code:
    Sub GetHSum(startControl As Integer, endControl As Integer)
        Dim xsum As Integer, i As Integer
        xsum = 0
        i = 0
        For i = startControl To endControl Step 5
            T = TryCast(FindControl("ctl00$MainContent$TextBox" & i), TextBox)
            If String.IsNullOrEmpty(T.Text) Then
                xsum = xsum + 0
            Else
                If xsum = 0 Then
                    xsum += Convert.ToInt32(T.Text)

                Else
                    xsum += Convert.ToInt32(T.Text)
                End If
            End If
        Next

        'Because the loop advances i by 5 before it quits the loop 
        'Eg: if range is given as 1,56 then i value will be 61 by the time it quits the loop
        T = TryCast(FindControl("ctl00$MainContent$TextBox" & i), TextBox)
        T.Text = xsum
        i = 0
    End Sub

Last edited by Upen1978; June 11th, 2013 at 06:56 AM.. Reason: No Response
 
Old June 19th, 2013, 03:56 PM
Registered User
 
Join Date: Jun 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascripot equivalent for VB.Net Code

Code:
Sub GetHSum(startControl As Integer, endControl As Integer)
        Dim xsum As Integer, i As Integer
        xsum = 0
        i = 0
        For i = startControl To endControl Step 5
            T = TryCast(FindControl("ctl00$MainContent$TextBox" & i), TextBox)
            If String.IsNullOrEmpty(T.Text) Then
                xsum = xsum + 0
            Else
                If xsum = 0 Then
                    xsum += Convert.ToInt32(T.Text)

                Else
                    xsum += Convert.ToInt32(T.Text)
                End If
            End If
        Next

        'Because the loop advances i by 5 before it quits the loop 
        'Eg: if range is given as 1,56 then i value will be 61 by the time it quits the loop
        T = TryCast(FindControl("ctl00$MainContent$TextBox" & i), TextBox)
        T.Text = xsum
        i = 0
    End Sub


//"ctl00$MainContent$TextBox" this iD is generating by asp so with javascript //is better than your html is like that:

//<asp:TextBox Id="myTextBox" ClientIDMode="Static"  runat="server" /> 

//nb: javascript is case sensitive
//Copnversion in javascript

<script type=text/javascript>
function GetHSum(startControl, endControl )
{
 var xsum, i ;
        xsum = 0;
        i = startControl;

        while (i < endControl )
        {
             T = getElementByID("ctl00$MainContent$TextBox" + i);
            If (T.text() == "")
{ xsum = xsum + 0; } Else If (xsum == 0) { xsum += parseFloat(T.Text()); Else xsum += parseFloat(T.Text()); }
} i +=5, } //end while T =getElementByID("ctl00$MainContent$TextBox" + i); T.Text(xsum); i = 0; } //end function </script>
 
Old January 22nd, 2015, 06:27 AM
Registered User
 
Join Date: Jan 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for sharing such information. I like that keep it up




___________________________
You can check out our latest security+ plus exam and written security+ pdf by our security plus certification cost to help you pass passguide.You can also purchase www.stevenson.edu Our Florida Southern College is simply excellent in quality.

Last edited by zzeplinispire; February 9th, 2015 at 01:35 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB equivalent of this C# code yukijocelyn ASP.NET 2.0 Basics 2 October 1st, 2007 10:22 PM
What is the Equivalent Syntax in VB.NET r_taduri VB.NET 2002/2003 Basics 1 June 2nd, 2006 12:49 PM
Equivalent of ListView.FindItem in VB.NET ashu_from_india VS.NET 2002/2003 1 October 24th, 2005 02:29 PM
What is C# Component equivalent to in VB.NET bekim C# 3 July 1st, 2004 03:24 PM
VB6! what is the VB.Net equivalent Louisa VB.NET 2002/2003 Basics 2 January 15th, 2004 12:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.