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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page tranfer using button

Status
Not open for further replies.

brd24gor

MIS
May 18, 2005
123
US
I have an ASP button that I want to perform a Server.Transfer when clicked. For some reason, when the button is clicked, the _Click event isn't fired and the page just performs a postback. I've that my _Click event is properly attached to be button, so I know the binding isn'the problem.

Any suggestions?
--B

"Life is too important to be taken seriously" --Albert Einstein
 
So, if you step through the code, does the event fire and does the Server.Transfer line execute?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Nope, nothing inside the event fires. I've put a breakpoint in there that doesn't get hit. The Server.Transfer line is the only code inside the event.

"Life is too important to be taken seriously" --Albert Einstein
 
But does the event itself fire?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Sorry for sounding a little ignorant, but I'm relatively new at this. How would I find out if the event is firing other than seeing if the event code is executing?

"Life is too important to be taken seriously" --Albert Einstein
 
Say for example you had this:
Code:
    Private Function myFunction()
        Server.Transfer("anotherpage.aspx")
    End Function
From what I understand, you have put a breakpoint on the middle line and it doesn't work (or it doesn't get hit). Put a breakpoint on the first line instead and see if that gets hit.

If it does, then there's a problem with the code inside of the function. If it doesn't get hit, there is a problem with the wiring of the event to this function.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Here is the event:
Code:
		public void transferButton_Click(object sender, System.EventArgs e)
		{
			Server.Transfer(adminMenu);
		}

I've tried breakpoints on the public and Server lines and neither one gets hit. I've also double-checked that the event is properly attached to the button.
Code:
		private void InitializeComponent()
		{    
			this.transferButton.Click += new System.EventHandler(this.transferButton_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}

Any ideas?

"Life is too important to be taken seriously" --Albert Einstein
 
dang...too much to do, unless you need it dynamically created...

in your html, try this first...

<asp:Button id=myButtonName runat=server text="Click Me" onClick=transferButton_Click></asp:Button>

if you dont want to or doesnt work...
dont know much bout initializing components in Vstudio, but should it not be...
this.transferButton.onClick += new System.EventHandler(this.transferButton_Click);

 
I've already tried putting the onClick in the HTML and I was getting an error that said it couldn't find transferButton_Click. I'll try changing the InitializeComponent() method to see if that works. Thanks for the tips!

--B

"Life is too important to be taken seriously" --Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top