Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameter value form aspx page to vb.net code (App_code) folde

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
I have a vb.net code with one class "letprop" in the APP_code folder. I am wondering if I could pass a value from the aspx page to the letprop class.
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        contract id =
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    
    </div>
    </form>
</body>
</html>

Code:
this code is in app_code folder---------
Imports Microsoft.VisualBasic
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Imports System.Data
Imports System.Configuration.ConfigurationManager

Public Class prop


    Private Shared Function GetConnectionString() As String
        Return ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
    End Function



  ----I would like to pass the parameter value to this function

    Public Shared Function GetLetProp() As DataSet
        Dim sel As String = "select lcontid, avendor,letting, datepub  from letprop where contractid = :txtContractId "
        Dim daLetprop As OracleDataAdapter = New OracleDataAdapter(sel, GetConnectionString)
        Dim dsLetProp As DataSet = New DataSet
        daLetprop.Fill(dsLetProp, "tLetprop")
        Return dsLetProp
    End Function
End Class

Code:
 
Yes. You need to create a constructor on your class that accepts the parameters you want to pass.
 
thank you jbenson001 for the reply. I did like you suggested and I got this error:
Argument not specified for parameter 'stContract' of 'Public Shared Function GetLetProp(stContract As String) As System.Data.DataSet'.

Code:
Imports Microsoft.VisualBasic
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Imports System.Data
Imports System.Configuration.ConfigurationManager

Public Class prop
    Dim stContract As Integer
    Public Sub New(ByVal myContract As String)
        stContract = myContract
    End Sub
    Private Shared Function GetConnectionString() As String
        Return ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
    End Function
    Public Shared Function GetLetProp(ByVal stContract As String) As DataSet
        Dim sel As String = "select lcontid, avendor,letting, datepub   from letprop where lcontid = :stContract "
        Dim daLetprop As OracleDataAdapter = New OracleDataAdapter(sel, GetConnectionString)
        Dim dsLetProp As DataSet = New DataSet
        daLetprop.Fill(dsLetProp, "tLetprop")
        Return dsLetProp
    End Function
End Class
[code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top