Help! Problems with calling a subroutine in a repe

Givigier

New Member
I have been banging my head on the wall about this one for days and I'm hoping all of you can help. In the code I will post further down I am trying to call a subroutine to set a session variable. This subroutine is called in the onclick method of the form button and the parameter it is passing is retrieved from our database and is the unique identifier for the table. Unfortunately, no matter how I attempt to format the code I get errors saying the server tag is not well formed. And AFAIK this is not the case, but it still does not work. You might want to copy and paste the code I have provided in notepad to get a better look at it. Any help is greatly appreciated.<BR><BR><%@ Page language="VB" Debug="true" Trace="True"%><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="System.Data.OLEDB" %><BR><%<BR>If Session("Authenticated") <> 1 And Session("AdminCheck") <> 1 Then<BR> Response.Redirect("default.aspx")<BR>End If<BR>%><BR><html><BR> <head><BR> <link rel=stylesheet href=http://aspmessageboard.com/archive/index.php/"style.css" type="text/css" /><BR> <script runat="server"><BR> Sub Page_Load<BR> If Not IsPostBack Then<BR> Dim myOleDbCommand as OleDbCommand<BR> Dim myOleDbConnection as OleDbConnection<BR><BR> Dim rightNow as DateTime = DateTime.Now<BR> myOleDbConnection = new OleDbConnection("Provider=MSDAORA;DSN=cltp*;User ID=user;Password=password")<BR> myOleDbCommand = New OleDbCommand("Select * From nbd_mfg.openjobs Where closeDate >='" + rightNow.ToString("dd-MMM-yy") + "'", myOleDbConnection )<BR> myOleDbConnection.Open()<BR> myRepeater.DataSource = myOleDbCommand.ExecuteReader()<BR> myRepeater.DataBind()<BR> myOleDbConnection.Close() <BR> End If<BR> End Sub<BR><BR> Sub foobar(line As String)<BR> Session("jobID") = line<BR> Response.Redirect("editOpenJob.aspx")<BR> End Sub<BR> </script><BR> </head><BR> <BR> <body> <BR> <form id="editJob" method="get" runat="server"><BR> <asp:Repeater id="myRepeater" runat="Server"> <BR> <ItemTemplate><BR> <hr><BR> Job Title: <%# Container.DataItem( "jobTitle" ) %>????Shift: <%# Container.DataItem( "shift" ) %>????Labor Grade: <%# Container.DataItem( "department" ) %><br /><BR> Date when job becomes available: <%# Container.DataItem( "openDate" ) %>????Date when job is no longer available: <%# Container.DataItem( "closeDate" ) %><br /><BR> <asp:Button text='Edit this Job' OnClick=foobar(<%# Container.DataItem("jobID").ToString() %>) runat="server" /><BR> </Itemtemplate><BR> </asp:Repeater><BR> </form><BR> </body><BR></html>Which line are you getting the error on? I have gotten this message when I forget to include the "/" in a tag.My apologies, I am getting the error on line 42 where I declare the server side form button. I'm afraid the error generated isn't more descriptive than that.When replacing the code segment <%# Container.DataItem("jobID").ToString() %> with an integer as what should be happening I get the error BC30577: 'AddressOf' operand must be the name of a method; no parentheses are needed. The detailed compiler output shows AddHandler __ctrl.Click, AddressOf Me.foobar(1).<BR><BR>When I remove the parantheses and have foobar 1 I get the error BC30408: Method 'Public Sub foobar(line As String)' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'. The detailed compiler output shows AddHandler __ctrl.Click, AddressOf Me.foobar.<BR><BR>When I put single or double quotes around the parameter I get the error, the server tag is not well formed again. When I put single or double quotes around the calling of the mothod and paramater ('foobar 1' and "foobar 1") I get the error BC30408: Method 'Public Sub foobar(line As String)' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)' again.<BR><BR>This is driving me batty. :(Sub foobar(line As String)<BR>Try this:<BR><BR><asp:Button text="Edit this Job" OnServerClick='foobar(<%# Container.DataItem("jobID")%>)' runat="server" /> <BR><BR>On Properties use Double Quotes ( text="")<BR>Any Property that needs to be binded use single Quotes.<BR>Use OnServerClick instead of OnClick().<BR>Do not think you need to use ".ToString()" since in foo you pass line in as String.<BR>Sub foobar(line As String)<BR><BR>Aaron<BR><BR>
 
Back
Top