sticar
asked on
Use OnClick event from another button link
I have an image and a hyperlink button. I want the image to go to the same link as the hyperlink.
Sub Mylink_Click ( attirbutes) Handles mylink_click
Server.Transfer(mylink.asp x)
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click() 'Doesn't work
End Sub
Isn't there a better way?
Sub Mylink_Click ( attirbutes) Handles mylink_click
Server.Transfer(mylink.asp
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click() 'Doesn't work
End Sub
Isn't there a better way?
Hi there...
use an "ImageButton"... instead of "Image"...
-Baan
use an "ImageButton"... instead of "Image"...
-Baan
ASKER
It actually is an ImageButton, sorry.
try
Sub Mylink_Click ( attirbutes) Handles mylink_click, myimage_click
Server.Transfer(mylink.asp x)
End Sub
Sub Mylink_Click ( attirbutes) Handles mylink_click, myimage_click
Server.Transfer(mylink.asp
End Sub
ASKER
rfgkey... I tried that one before and it said the paramaters were different for myimage_click
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I won't be able to try this for about 5 more hours. I'll let you know. Thanks for all the input.
sorry.. I was out for lunch...
ok.. if you want to execute the evant handler of the link from the Imgae Button.. do this...
Mylink_Click ( attirbutes)
inside the ImageButton_click. Parameter for this will be (sender, e)... no need to go for server.transfer.
-Baan
ok.. if you want to execute the evant handler of the link from the Imgae Button.. do this...
Mylink_Click ( attirbutes)
inside the ImageButton_click. Parameter for this will be (sender, e)... no need to go for server.transfer.
-Baan
ASKER
I'm not understanding what you're saying Baan. ?
ok... you want this... right?
<<
Sub Mylink_Click ( attirbutes) Handles mylink_click
Server.Transfer(mylink.asp x)
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click() 'Doesn't work
End Sub
>>
change Myimage_click...
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click(attributes) 'Will work (Attribute=> Sender,e)
End Sub
-Baan
<<
Sub Mylink_Click ( attirbutes) Handles mylink_click
Server.Transfer(mylink.asp
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click() 'Doesn't work
End Sub
>>
change Myimage_click...
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click(attributes) 'Will work (Attribute=> Sender,e)
End Sub
-Baan
ASKER
That is what I actually have, it starts redirecting it but I think it gets messed up somehow because in my link I have a raise event too...
Sub mylink_click (attributes)
Raise.Myevent( sender, e)
Server.Transfer(mylink.asp x)
End Sub
Sub mylink_click (attributes)
Raise.Myevent( sender, e)
Server.Transfer(mylink.asp
End Sub
hmmm... well.. did you try Response.Redirect("mylink. aspx") ? might work
-Baan
-Baan
The reason why
Sub Mylink_Click ( attirbutes) Handles mylink_click
Server.Transfer(mylink.asp x)
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click() 'Doesn't work
End Sub
Because when a click is called as an event ( that is when you click stuff ) certain arguments are passed automatically to the the event handler hence if you manually call the click event it will not work. I would suggest the best solution to be what rfgkev mentioned above..
Sub Mylink_Click ( attirbutes) Handles mylink_click
DoTransfer()
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
DoTransfer()
End Sub
Private Sub DoTransfer
Server.Transfer(mylink.asp x)
End Sub
hth
--yatharth
Sub Mylink_Click ( attirbutes) Handles mylink_click
Server.Transfer(mylink.asp
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
Mylink_Click() 'Doesn't work
End Sub
Because when a click is called as an event ( that is when you click stuff ) certain arguments are passed automatically to the the event handler hence if you manually call the click event it will not work. I would suggest the best solution to be what rfgkev mentioned above..
Sub Mylink_Click ( attirbutes) Handles mylink_click
DoTransfer()
End Sub
Sub Myimage_Click ( attributes) Handles myimage_click
DoTransfer()
End Sub
Private Sub DoTransfer
Server.Transfer(mylink.asp
End Sub
hth
--yatharth
mylink.PerformClick() ' assuming that button has mylink name
End Sub