convert VB function in ASP to ASP.Net

Last post 07-13-2009 12:01 PM by khparhami. 2 replies.

Sort Posts:

  • convert VB function in ASP to ASP.Net

    07-13-2009, 11:13 AM
    • Member
      30 point Member
    • ryanlcs
    • Member since 05-17-2007, 1:35 PM
    • Posts 238

     Hi

    I have these Sub (vbscript) in ASP, now I am converting them to ASP.Net, but have no idea how to go about it:

    Sub Window_OnLoad() 
            Clear_Form(0) 
          End Sub 
          
          Sub Clear_Form(status) 
            if(status <> 0) then 
                confirmClear=MsgBox ("Are you sure you want to clear form?", 36,"Confirm Clear Form")  
            else confirmClear=6
            end if
            
            if(confirmClear = 6) then 
              document.form_choice.txtEmpId.value = "" 
              document.form_choice.optShift.value = "" 
              document.form_choice.cmdSubmit.disabled = True 
              document.form_choice.txtOthers1.value = "" 
              document.form_choice.txtOthers2.value = "" 
              
              'Add by CHLEE at 25 Oct 2007
              document.form_choice.txtRemeasured.value = ""
              document.form_choice.txtResampling.value = ""
              
              If intRCFound = 1 Then
    			'Root Cause
    			for i = 1 to actionCount 
    			document.form_choice.A&i.checked = false
    			next
              
    			'Root Cause TextBox Remark Clear, Add by CHLEE at 1 Nov 2007
    			for i = 1 to actionCount
    			document.form_choice.txtARemark & radioRCArray(i-1) & .value = ""
    			next
              End If
              
              If intCAFound = 1 Then
    			'CA TextBox Remark Clear, Add by CHLEE at 1 Nov 2007
    			for i = 1 to actionCount2
    			document.form_choice.txtBRemark & radioCAArray(i-1).value = ""
    			next
              
    			'CA
    			for i = 1 to actionCount2
    			document.form_choice.B & i .checked = false 
    			next
              End If
              
              'Add by CHLEE at 25 Oct 2007
              document.form_choice.B_1.checked = false
              document.form_choice.B_2.checked = false
              
              document.form_choice.A0.checked = false
              document.form_choice.B0.checked = false
              
              document.form_choice.txtEmpId.focus() 
            end if 
          end sub


     

    I tried to place the code in .aspx page, but hit with unknown error, then I put it in .aspx.vb, but the "document" element is not recognized.

    Please help.

     

  • Re: convert VB function in ASP to ASP.Net

    07-13-2009, 11:58 AM
    • Member
      89 point Member
    • swolff1978
    • Member since 04-15-2009, 2:53 PM
    • Posts 77

    I'm relatively new to vb programming but I would start by making sure your .aspx page has all the controls referenced by the code.  Then in the .vb file,  try removing the words "document.form_choice" and replace them with "Me".  You may also need to change the Window_OnLoad to either

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    or

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



  • Re: convert VB function in ASP to ASP.Net

    07-13-2009, 12:01 PM
    • Member
      409 point Member
    • khparhami
    • Member since 04-09-2009, 1:19 AM
    • Tehran
    • Posts 189

     Hi,

    Migrating from ASP to ASP.NET is not that easy bu it depends on the code. As I can see in your code you can do it by putting the related controles into the aspx page (textboxes, radio buttons and ...) , you know better what you have in your page and you can substitute them by the relevent .NET controls. I found the following link very usefull, please check :

    http://msdn.microsoft.com/en-us/asp.net/aa336623.aspx

     

    good luck

    Best regards
    Khashayar

    ---------------------------------------------
    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
Page 1 of 1 (3 items)