Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to passing a panel id to to a sub routine with a onclick on a button with VB.Net

 

I have several panels that I want to make visible or invisible, I want to create one sub to the same routine.

 

ex.

 

 

sub runIt(a as object, e as eventargs, pnlName as string)

if a.text="+" then

pnlName.visible=true

' pnlTravel.visible=true This works fine

a.text="-"

else

pnlName.visible=false

' pnlTravel.visible=false this works fine

a.text="+"

end if

End sub

 

 

<asp:Button id="btnAdd2" onclick="runIt('pnlTravel')" runat="server" Font-Size="XX-Small" BorderStyle="Solid" Text="+" BackColor="White" BorderColor="DarkGray" />

<asp:Panel id="pnlTravel" runat="server">My code goes here</asp:Panel>

 

Please help I'm new to .NET

 

James

Posted

I've declare the parameter as a panel. But how do I pass the panel itself? can you show me an example?

sub runIt(a as object, e as eventargs, pnlName as panel)

if a.text="+" then

pnlName.visible=true

a.text="-"

else

pnlName.visible=false

a.text="+"

end if

End sub

 

<asp:Button id="btnAdd2" onclick="runIt(pnlTravel)" runat="server" Font-Size="XX-Small" BorderStyle="Solid" Text="+" BackColor="White" BorderColor="DarkGray" />

<asp:Panel id="pnlTravel" runat="server">My code goes here</asp:Panel>

 

Thanks,

 

James

Posted

When I pass the panel name to the subroutine The subroutine is expecting values for "a as object, e as eventargs". If I take them out of the subroutine. I get a message telling me I need them. Is there a way I can pass the object and eventargs with the panel name?

 

James

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...