Passing Arguments?

K

Kris Rockwell

Hello,

I have created Sub that requires one argument which is a string. However,
when I run the Sub, the string is not passed as it should be. Here is the
code

Public Sub fCrewLookup(ByVal x As String)

CrewPos = x
Me.AddCrew.Visible = False
Me.CrewLookup.Visible = True
SqlDataAdapter3.Fill(DataSet41)
dgCrewLookup.SelectedIndex() = -1
dgCrewLookup.DataBind()

End Sub

Private Sub ibPFLookup_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ibPFLookup.Click

fCrewLookup("PF")

End Sub

And finally what is supposed to be the result:

Private Sub CrewLookupSelect_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CrewLookupSelect.Click

If dgCrewLookup.SelectedIndex < 0 Then

MessageBox.Show("Please select a crew member.", "Selection Error",
MessageBoxButtons.OK, MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)

Else

Dim sUID As String

sUID = dgCrewLookup.SelectedItem.Cells(0).Text()

PFID.Text = CrewPos

Me.CrewLookup.Visible = False

Me.AddCrew.Visible = True

End If

End Sub

End Class



The variable CrewPos is declared as a variable in the Public Class block so
that it is global in scope to the entire application.What am I missing that
is not causing the argument to be passed? This works fin in VB.NET, but not
using VB in ASP.NET.



Thanks in advance,

Kris
 
A

Alvin Bruney [MVP]

gowd, i hate to look at vb code...arggggghhhh

The web environment operates differently than the windows environment. Your
CrewPos = x assignment lasts exactly as long as the sub routine executes
then it is gone. You will need to persist it to storage so it can survive
the posting process. If you store it in viewstate for example, then when you
need it in the click routine, pull it out of viewstate and use it.

On each post, nothing lasts unless it is explicitly stored in a database, or
cached in storage.

It may be worth your while to read up a little on the web architecture and
the ASP.NET paradigm
 
K

Kris Rockwell

Alvin,

Thanks for your reply. It has cleared up a few things.

I am actually quite familiar with web achitecture, it just happens to be the
old ASP that I have worked with. I'd love to make the jump to using C#, but
time doesn't allow for that at this point.

Regards,
Kris


Alvin Bruney said:
gowd, i hate to look at vb code...arggggghhhh

The web environment operates differently than the windows environment. Your
CrewPos = x assignment lasts exactly as long as the sub routine executes
then it is gone. You will need to persist it to storage so it can survive
the posting process. If you store it in viewstate for example, then when you
need it in the click routine, pull it out of viewstate and use it.

On each post, nothing lasts unless it is explicitly stored in a database, or
cached in storage.

It may be worth your while to read up a little on the web architecture and
the ASP.NET paradigm
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
message news:[email protected]...
Hello,

I have created Sub that requires one argument which is a string. However,
when I run the Sub, the string is not passed as it should be. Here is the
code

Public Sub fCrewLookup(ByVal x As String)

CrewPos = x
Me.AddCrew.Visible = False
Me.CrewLookup.Visible = True
SqlDataAdapter3.Fill(DataSet41)
dgCrewLookup.SelectedIndex() = -1
dgCrewLookup.DataBind()

End Sub

Private Sub ibPFLookup_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ibPFLookup.Click

fCrewLookup("PF")

End Sub

And finally what is supposed to be the result:

Private Sub CrewLookupSelect_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles CrewLookupSelect.Click

If dgCrewLookup.SelectedIndex < 0 Then

MessageBox.Show("Please select a crew member.", "Selection Error",
MessageBoxButtons.OK, MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)

Else

Dim sUID As String

sUID = dgCrewLookup.SelectedItem.Cells(0).Text()

PFID.Text = CrewPos

Me.CrewLookup.Visible = False

Me.AddCrew.Visible = True

End If

End Sub

End Class



The variable CrewPos is declared as a variable in the Public Class block
so
that it is global in scope to the entire application.What am I missing
that
is not causing the argument to be passed? This works fin in VB.NET, but
not
using VB in ASP.NET.



Thanks in advance,

Kris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top