vb functions evaluating on load

G

Guest

Hi there, I have created a vb server function which i want to evaluate when a server control button is clicked (only!) however it is evaluating the code on load even though i havent put it into the page_load function. why is it evaluating and not waiting for the calling click event? I have made it just plain sub. not private or anything FYI and have put it in the CBPage. thanks.
 
C

Craig Deelsnyder

Hi there, I have created a vb server function which i want to evaluate
when a server control button is clicked (only!) however it is evaluating
the code on load even though i havent put it into the page_load
function. why is it evaluating and not waiting for the calling click
event? I have made it just plain sub. not private or anything FYI and
have put it in the CBPage. thanks.

Can you share some code? Show us the code/event where the function is
called, etc.
 
L

Lucas Tam

=?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
Hi there, I have created a vb server function which i want to evaluate
when a server control button is clicked (only!) however it is
evaluating the code on load even though i havent put it into the
page_load function. why is it evaluating and not waiting for the
calling click event? I have made it just plain sub. not private or
anything FYI and have put it in the CBPage. thanks.

This doesn't make too much sense...

Are you saying the Page_Load is run before your event handler is firing?
This is because ASP.NET needs to recreate the page before any event
handlers are fired.
 
G

Guest

ok i have a function in my aspx.vb code behind page called get_xml. it does some reading on an xml file and returns it to the browser. But i only want it to fire when a button is clicked so i have this on my aspx page:


<input type="button" id="getxmlbutton" onserverclick="get_xml" value="edit xml" runat="server">

and this function in my aspx.vb CB page

Sub get_xml(ByVal sender As System.Object, ByVal e As System.EventArgs)
blah blah
End Sub

my page_load is empty. But instead of this function waiting for the button to fire the event on the onserverclick, it runs it on load, so it goes and fetches xml before the user has even entered an xml file in a field. why is it running the function?
 
K

Kevin Spencer

Forget about Page_Load. Your problem has nothing to do with Page_Load.
Page_Load is simply an event that happens, among many others. You have
defined a Sub that executes a certain functionality. Now, are you saying
that this Sub runs EVERY TIME the page is requested, regardles of PostBack
or any user events? If not, precisely what conditions cause this Sub to run?
Also, is there any code in the page, or in any of the controls in the page,
that calls this Sub?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

louise raisbeck said:
ok i have a function in my aspx.vb code behind page called get_xml. it
does some reading on an xml file and returns it to the browser. But i only
want it to fire when a button is clicked so i have this on my aspx page:
<input type="button" id="getxmlbutton" onserverclick="get_xml" value="edit xml" runat="server">

and this function in my aspx.vb CB page

Sub get_xml(ByVal sender As System.Object, ByVal e As System.EventArgs)
blah blah
End Sub

my page_load is empty. But instead of this function waiting for the button
to fire the event on the onserverclick, it runs it on load, so it goes and
fetches xml before the user has even entered an xml file in a field. why is
it running the function?
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top