I'm trying to raise the click event of a button from my Page_Load event so
that after the Page_Load completes the myBtn_Click event is fired, just as if
a user had clicked the button. I can't just call myBtn_Click, page_load must
complete first just as it would if a user had clicked. I keep getting an
error telling me to set the page's EnableEventValidation to false, but I
don't want to do that. For testing, I did set it to false and used
"DirectCast(myBtn, IPostBackEventHandler).RaisePostBackEvent(Nothing) " to
raise the click event, but myBtn_Click was called immediately, not after
Page_Load.
Can anyone help with a specific VB example? 4 1500
I'd suggest putting the entire action you have inside the click event into
its own subroutine -
Then, in the click event of the button, just call that subroutine
That way, you can call the routine in anyway you'd like from anywhere
(dynamically or otherwise)
David Wier http://aspnet101.com http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"smay" <sm**@discussions.microsoft.comwrote in message
news:27**********************************@microsof t.com...
I'm trying to raise the click event of a button from my Page_Load event so
that after the Page_Load completes the myBtn_Click event is fired, just as
if
a user had clicked the button. I can't just call myBtn_Click, page_load
must
complete first just as it would if a user had clicked. I keep getting an
error telling me to set the page's EnableEventValidation to false, but I
don't want to do that. For testing, I did set it to false and used
"DirectCast(myBtn, IPostBackEventHandler).RaisePostBackEvent(Nothing) " to
raise the click event, but myBtn_Click was called immediately, not after
Page_Load.
Can anyone help with a specific VB example?
You could have this code in its own routine so that your handlers (or
whetver place you want) can just call the real sttuff (rather than
"embedding" this code).
Else you could use LoadComplete if you really need to have this done after
page_load (not even at the end of this event).
As usual knowing a bit more what you are trying to do (and why you need to
fake a user click) could raise more focused suggestions...
--
Patrice
"smay" <sm**@discussions.microsoft.coma écrit dans le message de news: 27**********************************@microsoft.com...
I'm trying to raise the click event of a button from my Page_Load event so
that after the Page_Load completes the myBtn_Click event is fired, just as
if
a user had clicked the button. I can't just call myBtn_Click, page_load
must
complete first just as it would if a user had clicked. I keep getting an
error telling me to set the page's EnableEventValidation to false, but I
don't want to do that. For testing, I did set it to false and used
"DirectCast(myBtn, IPostBackEventHandler).RaisePostBackEvent(Nothing) " to
raise the click event, but myBtn_Click was called immediately, not after
Page_Load.
Can anyone help with a specific VB example?
Problem is the button is not visible to the user. It was just my way of
forcing code to run after the Page_Load completes. Any suggestions on a
better/different way?
"David Wier" wrote:
I'd suggest putting the entire action you have inside the click event into
its own subroutine -
Then, in the click event of the button, just call that subroutine
That way, you can call the routine in anyway you'd like from anywhere
(dynamically or otherwise)
David Wier http://aspnet101.com http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"smay" <sm**@discussions.microsoft.comwrote in message
news:27**********************************@microsof t.com...
I'm trying to raise the click event of a button from my Page_Load event so
that after the Page_Load completes the myBtn_Click event is fired, just as
if
a user had clicked the button. I can't just call myBtn_Click, page_load
must
complete first just as it would if a user had clicked. I keep getting an
error telling me to set the page's EnableEventValidation to false, but I
don't want to do that. For testing, I did set it to false and used
"DirectCast(myBtn, IPostBackEventHandler).RaisePostBackEvent(Nothing) " to
raise the click event, but myBtn_Click was called immediately, not after
Page_Load.
Can anyone help with a specific VB example?
As Patrice said - you can call the routine I suggested in either the
LoadComplete or PreRender events
David Wier http://aspnet101.com http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"smay" <sm**@discussions.microsoft.comwrote in message
news:BB**********************************@microsof t.com...
Problem is the button is not visible to the user. It was just my way of
forcing code to run after the Page_Load completes. Any suggestions on a
better/different way?
"David Wier" wrote:
>I'd suggest putting the entire action you have inside the click event into its own subroutine - Then, in the click event of the button, just call that subroutine
That way, you can call the routine in anyway you'd like from anywhere (dynamically or otherwise)
David Wier http://aspnet101.com http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no bloated markup
"smay" <sm**@discussions.microsoft.comwrote in message news:27**********************************@microso ft.com...
I'm trying to raise the click event of a button from my Page_Load event
so
that after the Page_Load completes the myBtn_Click event is fired, just
as
if
a user had clicked the button. I can't just call myBtn_Click,
page_load
must
complete first just as it would if a user had clicked. I keep getting
an
error telling me to set the page's EnableEventValidation to false, but
I
don't want to do that. For testing, I did set it to false and used
"DirectCast(myBtn, IPostBackEventHandler).RaisePostBackEvent(Nothing) "
to
raise the click event, but myBtn_Click was called immediately, not
after
Page_Load.
Can anyone help with a specific VB example?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Donald Xie |
last post by:
Hi,
I noticed an interesting effect when working with controls that are
dynamically loaded. For instance, on a web form with a PlaceHolder control
named ImageHolder, I dynamically add an image...
|
by: Earl Teigrob |
last post by:
PROBLEM:
When a user control is loaded into a PlaceHolder control more than once, the
events do not fire on the first click of a control on the dynamically loaded
user control. In other words, the...
|
by: simon |
last post by:
On code behind file:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim ctrl As New LinkButton
ctrl.ID =...
|
by: R Duke |
last post by:
I have tried everything I can think of to change the visible property
of a design time created control from a dynamically created control's
command event handler.
Here is the scenario.
I have...
|
by: Kamal Jeet Singh |
last post by:
Hi Friends !!
I am have facing problem in controlling the dynamically created
controls on web page. The problem Scenario is
Scenario:- My requirement is to load the web user controls on the...
|
by: Kamal Jeet Singh |
last post by:
Hi Friends !!
I am facing problem in controlling the dynamically created
controls on web page. The problem Scenario is
Scenario:- My requirement is to load the web user controls on the web...
|
by: Steve Booth |
last post by:
I have a web form with a button and a placeholder, the button adds a user
control to the placeholder (and removes any existing controls). The user
control contains a single button. I have done all...
|
by: Bjorn Sagbakken |
last post by:
Hello
In VS2005:
I am adding buttons and textboxes dynamically into a table, that also
dynamically expands.
So far, so good, actually very nice.
But I am having trouble starting the desired...
|
by: Amoril |
last post by:
I've read quite a few different message on various boards and for some
reason I'm still having trouble wrapping my head around this viewstate
maintenance and trying to get these dynamically created...
|
by: Allen Chen [MSFT] |
last post by:
Hi Richard,
Quote from Richard==================================================
However I also want to be able to remove the
panes. I have tried to include this, but find that when I first...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |