473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Button events

Hi,

I have created a control with some buttons an alphabet. When one of these
buttons are pressed it posts back and in the postback event for the button
pressed a list of tems is created with a list of buttons next to them to
delete the term. My problem is that the delete button has a delete event
attached to it but t does not fire. Is this because the delete butons are
created in the postbaclk event and not the CreateChildControls method - and
if so how do I fix this.

Jim
Dec 20 '05 #1
7 1850
Jim:
The entire state of the page needs to be created when a button is clicked.
So when you press a delete button, you need to make sure that whatever
controls were loaded when a alphabet-button was clicked are loaded.

My guess is that the delete button isn't re-created on postback, so the
event never fires. A typical way to solve this is to store some info in the
viewstate. Here's some pseudocode:

sub AlphabetButton_click(...)
LoadYourTerms(e.CommandArgument)
ViewState.Add("Letter", e.CommandArgument)
end sub

sub page_load(...)
'IF we are posting back AND there's a letter stored in the viewstate
if Page.IsPostBack AndAlso not ViewState("Letter") is nothing then
LoadYourTerms(ViewState("Letter"))
end if
end sub
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
Hi,

I have created a control with some buttons an alphabet. When one of these
buttons are pressed it posts back and in the postback event for the button
pressed a list of tems is created with a list of buttons next to them to
delete the term. My problem is that the delete button has a delete event
attached to it but t does not fire. Is this because the delete butons are
created in the postbaclk event and not the CreateChildControls method -
and
if so how do I fix this.

Jim

Dec 20 '05 #2
Hi Karl,
I cannot load up the terms, in the control I created the letter selected is
not know until the

AlphabetButton_Click(...)

and all the controls have been written by then

Jim

"Karl Seguin" wrote:
Jim:
The entire state of the page needs to be created when a button is clicked.
So when you press a delete button, you need to make sure that whatever
controls were loaded when a alphabet-button was clicked are loaded.

My guess is that the delete button isn't re-created on postback, so the
event never fires. A typical way to solve this is to store some info in the
viewstate. Here's some pseudocode:

sub AlphabetButton_click(...)
LoadYourTerms(e.CommandArgument)
ViewState.Add("Letter", e.CommandArgument)
end sub

sub page_load(...)
'IF we are posting back AND there's a letter stored in the viewstate
if Page.IsPostBack AndAlso not ViewState("Letter") is nothing then
LoadYourTerms(ViewState("Letter"))
end if
end sub
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
Hi,

I have created a control with some buttons an alphabet. When one of these
buttons are pressed it posts back and in the postback event for the button
pressed a list of tems is created with a list of buttons next to them to
delete the term. My problem is that the delete button has a delete event
attached to it but t does not fire. Is this because the delete butons are
created in the postbaclk event and not the CreateChildControls method -
and
if so how do I fix this.

Jim


Dec 20 '05 #3
Not sure I understand.

There are a bunch of letters
User clicks one
There are a bunch of terms
User clicks one
Term is deleted
If you look at my example, every time a letter is clicked, that value is
stored in the viewstate. Your problem is that when a term is clicked, the
letter isn't reloaded, hence the term isn't deleted. In my example, the
value from the viewstate is read during Page_Load and the page is returned
to it's previous state.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Hi Karl,
I cannot load up the terms, in the control I created the letter selected
is
not know until the

AlphabetButton_Click(...)

and all the controls have been written by then

Jim

"Karl Seguin" wrote:
Jim:
The entire state of the page needs to be created when a button is
clicked.
So when you press a delete button, you need to make sure that whatever
controls were loaded when a alphabet-button was clicked are loaded.

My guess is that the delete button isn't re-created on postback, so the
event never fires. A typical way to solve this is to store some info in
the
viewstate. Here's some pseudocode:

sub AlphabetButton_click(...)
LoadYourTerms(e.CommandArgument)
ViewState.Add("Letter", e.CommandArgument)
end sub

sub page_load(...)
'IF we are posting back AND there's a letter stored in the viewstate
if Page.IsPostBack AndAlso not ViewState("Letter") is nothing then
LoadYourTerms(ViewState("Letter"))
end if
end sub
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
> Hi,
>
> I have created a control with some buttons an alphabet. When one of
> these
> buttons are pressed it posts back and in the postback event for the
> button
> pressed a list of tems is created with a list of buttons next to them
> to
> delete the term. My problem is that the delete button has a delete
> event
> attached to it but t does not fire. Is this because the delete butons
> are
> created in the postbaclk event and not the CreateChildControls method -
> and
> if so how do I fix this.
>
> Jim


Dec 20 '05 #4
Hi Karl,

No not quiet, The control loads on CreateChildControls the alphabet buttons
are created with a ConnandEventHandler connected. Whan a user presses a
letter I use Viewstate to record the letter then show the terms and buttons
next to them with a ConnandEventHandler connected. When a delete button is
pressed it posts back but does not go into the EventHandler where the delete
functionality is held. Thas the problem

Jim
"Karl Seguin" wrote:
Not sure I understand.

There are a bunch of letters
User clicks one
There are a bunch of terms
User clicks one
Term is deleted
If you look at my example, every time a letter is clicked, that value is
stored in the viewstate. Your problem is that when a term is clicked, the
letter isn't reloaded, hence the term isn't deleted. In my example, the
value from the viewstate is read during Page_Load and the page is returned
to it's previous state.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Hi Karl,
I cannot load up the terms, in the control I created the letter selected
is
not know until the

AlphabetButton_Click(...)

and all the controls have been written by then

Jim

"Karl Seguin" wrote:
Jim:
The entire state of the page needs to be created when a button is
clicked.
So when you press a delete button, you need to make sure that whatever
controls were loaded when a alphabet-button was clicked are loaded.

My guess is that the delete button isn't re-created on postback, so the
event never fires. A typical way to solve this is to store some info in
the
viewstate. Here's some pseudocode:

sub AlphabetButton_click(...)
LoadYourTerms(e.CommandArgument)
ViewState.Add("Letter", e.CommandArgument)
end sub

sub page_load(...)
'IF we are posting back AND there's a letter stored in the viewstate
if Page.IsPostBack AndAlso not ViewState("Letter") is nothing then
LoadYourTerms(ViewState("Letter"))
end if
end sub
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
> Hi,
>
> I have created a control with some buttons an alphabet. When one of
> these
> buttons are pressed it posts back and in the postback event for the
> button
> pressed a list of tems is created with a list of buttons next to them
> to
> delete the term. My problem is that the delete button has a delete
> event
> attached to it but t does not fire. Is this because the delete butons
> are
> created in the postbaclk event and not the CreateChildControls method -
> and
> if so how do I fix this.
>
> Jim


Dec 20 '05 #5
I understand the problem. The reason the eventHandler is never executed, is
because the delete button no longer exists. The only way to make it exist
is to recreate it. To recreate it, you must simulate the
CommandEventHandler being clicked.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.com...
Hi Karl,

No not quiet, The control loads on CreateChildControls the alphabet
buttons
are created with a ConnandEventHandler connected. Whan a user presses a
letter I use Viewstate to record the letter then show the terms and
buttons
next to them with a ConnandEventHandler connected. When a delete button is
pressed it posts back but does not go into the EventHandler where the
delete
functionality is held. Thas the problem

Jim
"Karl Seguin" wrote:
Not sure I understand.

There are a bunch of letters
User clicks one
There are a bunch of terms
User clicks one
Term is deleted
If you look at my example, every time a letter is clicked, that value is
stored in the viewstate. Your problem is that when a term is clicked,
the
letter isn't reloaded, hence the term isn't deleted. In my example, the
value from the viewstate is read during Page_Load and the page is
returned
to it's previous state.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
> Hi Karl,
> I cannot load up the terms, in the control I created the letter
> selected
> is
> not know until the
>
> AlphabetButton_Click(...)
>
> and all the controls have been written by then
>
> Jim
>
> "Karl Seguin" wrote:
>
>> Jim:
>> The entire state of the page needs to be created when a button is
>> clicked.
>> So when you press a delete button, you need to make sure that whatever
>> controls were loaded when a alphabet-button was clicked are loaded.
>>
>> My guess is that the delete button isn't re-created on postback, so
>> the
>> event never fires. A typical way to solve this is to store some info
>> in
>> the
>> viewstate. Here's some pseudocode:
>>
>> sub AlphabetButton_click(...)
>> LoadYourTerms(e.CommandArgument)
>> ViewState.Add("Letter", e.CommandArgument)
>> end sub
>>
>> sub page_load(...)
>> 'IF we are posting back AND there's a letter stored in the viewstate
>> if Page.IsPostBack AndAlso not ViewState("Letter") is nothing then
>> LoadYourTerms(ViewState("Letter"))
>> end if
>> end sub
>>
>>
>> Karl
>>
>> --
>> MY ASP.Net tutorials
>> http://www.openmymind.net/
>> http://openmymind.net/redirector.aspx?documentId=51 - Learn about
>> AJAX!
>>
>>
>>
>> "Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
>> news:7C**********************************@microsof t.com...
>> > Hi,
>> >
>> > I have created a control with some buttons an alphabet. When one of
>> > these
>> > buttons are pressed it posts back and in the postback event for the
>> > button
>> > pressed a list of tems is created with a list of buttons next to
>> > them
>> > to
>> > delete the term. My problem is that the delete button has a delete
>> > event
>> > attached to it but t does not fire. Is this because the delete
>> > butons
>> > are
>> > created in the postbaclk event and not the CreateChildControls
>> > method -
>> > and
>> > if so how do I fix this.
>> >
>> > Jim
>>
>>
>>


Dec 20 '05 #6
Hi Karl,

Thanks for all your hel;p but how do you do that?

Jim

"Karl Seguin" wrote:
I understand the problem. The reason the eventHandler is never executed, is
because the delete button no longer exists. The only way to make it exist
is to recreate it. To recreate it, you must simulate the
CommandEventHandler being clicked.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.com...
Hi Karl,

No not quiet, The control loads on CreateChildControls the alphabet
buttons
are created with a ConnandEventHandler connected. Whan a user presses a
letter I use Viewstate to record the letter then show the terms and
buttons
next to them with a ConnandEventHandler connected. When a delete button is
pressed it posts back but does not go into the EventHandler where the
delete
functionality is held. Thas the problem

Jim
"Karl Seguin" wrote:
Not sure I understand.

There are a bunch of letters
User clicks one
There are a bunch of terms
User clicks one
Term is deleted
If you look at my example, every time a letter is clicked, that value is
stored in the viewstate. Your problem is that when a term is clicked,
the
letter isn't reloaded, hence the term isn't deleted. In my example, the
value from the viewstate is read during Page_Load and the page is
returned
to it's previous state.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
> Hi Karl,
> I cannot load up the terms, in the control I created the letter
> selected
> is
> not know until the
>
> AlphabetButton_Click(...)
>
> and all the controls have been written by then
>
> Jim
>
> "Karl Seguin" wrote:
>
>> Jim:
>> The entire state of the page needs to be created when a button is
>> clicked.
>> So when you press a delete button, you need to make sure that whatever
>> controls were loaded when a alphabet-button was clicked are loaded.
>>
>> My guess is that the delete button isn't re-created on postback, so
>> the
>> event never fires. A typical way to solve this is to store some info
>> in
>> the
>> viewstate. Here's some pseudocode:
>>
>> sub AlphabetButton_click(...)
>> LoadYourTerms(e.CommandArgument)
>> ViewState.Add("Letter", e.CommandArgument)
>> end sub
>>
>> sub page_load(...)
>> 'IF we are posting back AND there's a letter stored in the viewstate
>> if Page.IsPostBack AndAlso not ViewState("Letter") is nothing then
>> LoadYourTerms(ViewState("Letter"))
>> end if
>> end sub
>>
>>
>> Karl
>>
>> --
>> MY ASP.Net tutorials
>> http://www.openmymind.net/
>> http://openmymind.net/redirector.aspx?documentId=51 - Learn about
>> AJAX!
>>
>>
>>
>> "Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
>> news:7C**********************************@microsof t.com...
>> > Hi,
>> >
>> > I have created a control with some buttons an alphabet. When one of
>> > these
>> > buttons are pressed it posts back and in the postback event for the
>> > button
>> > pressed a list of tems is created with a list of buttons next to
>> > them
>> > to
>> > delete the term. My problem is that the delete button has a delete
>> > event
>> > attached to it but t does not fire. Is this because the delete
>> > butons
>> > are
>> > created in the postbaclk event and not the CreateChildControls
>> > method -
>> > and
>> > if so how do I fix this.
>> >
>> > Jim
>>
>>
>>


Dec 20 '05 #7
I still think my code is the right way to go.

As an alternative, you can look at Denis Bauer's free dynamic placeholder
control:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
Hi Karl,

Thanks for all your hel;p but how do you do that?

Jim

"Karl Seguin" wrote:
I understand the problem. The reason the eventHandler is never executed,
is
because the delete button no longer exists. The only way to make it
exist
is to recreate it. To recreate it, you must simulate the
CommandEventHandler being clicked.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.com...
> Hi Karl,
>
> No not quiet, The control loads on CreateChildControls the alphabet
> buttons
> are created with a ConnandEventHandler connected. Whan a user presses a
> letter I use Viewstate to record the letter then show the terms and
> buttons
> next to them with a ConnandEventHandler connected. When a delete button
> is
> pressed it posts back but does not go into the EventHandler where the
> delete
> functionality is held. Thas the problem
>
> Jim
> "Karl Seguin" wrote:
>
>> Not sure I understand.
>>
>> There are a bunch of letters
>> User clicks one
>> There are a bunch of terms
>> User clicks one
>> Term is deleted
>>
>>
>> If you look at my example, every time a letter is clicked, that value
>> is
>> stored in the viewstate. Your problem is that when a term is clicked,
>> the
>> letter isn't reloaded, hence the term isn't deleted. In my example,
>> the
>> value from the viewstate is read during Page_Load and the page is
>> returned
>> to it's previous state.
>>
>> Karl
>>
>> --
>> MY ASP.Net tutorials
>> http://www.openmymind.net/
>> http://openmymind.net/redirector.aspx?documentId=51 - Learn about
>> AJAX!
>>
>>
>>
>> "Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
>> news:8A**********************************@microsof t.com...
>> > Hi Karl,
>> > I cannot load up the terms, in the control I created the letter
>> > selected
>> > is
>> > not know until the
>> >
>> > AlphabetButton_Click(...)
>> >
>> > and all the controls have been written by then
>> >
>> > Jim
>> >
>> > "Karl Seguin" wrote:
>> >
>> >> Jim:
>> >> The entire state of the page needs to be created when a button is
>> >> clicked.
>> >> So when you press a delete button, you need to make sure that
>> >> whatever
>> >> controls were loaded when a alphabet-button was clicked are loaded.
>> >>
>> >> My guess is that the delete button isn't re-created on postback, so
>> >> the
>> >> event never fires. A typical way to solve this is to store some
>> >> info
>> >> in
>> >> the
>> >> viewstate. Here's some pseudocode:
>> >>
>> >> sub AlphabetButton_click(...)
>> >> LoadYourTerms(e.CommandArgument)
>> >> ViewState.Add("Letter", e.CommandArgument)
>> >> end sub
>> >>
>> >> sub page_load(...)
>> >> 'IF we are posting back AND there's a letter stored in the
>> >> viewstate
>> >> if Page.IsPostBack AndAlso not ViewState("Letter") is nothing
>> >> then
>> >> LoadYourTerms(ViewState("Letter"))
>> >> end if
>> >> end sub
>> >>
>> >>
>> >> Karl
>> >>
>> >> --
>> >> MY ASP.Net tutorials
>> >> http://www.openmymind.net/
>> >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about
>> >> AJAX!
>> >>
>> >>
>> >>
>> >> "Jimmy Jazz" <Ji*******@discussions.microsoft.com> wrote in message
>> >> news:7C**********************************@microsof t.com...
>> >> > Hi,
>> >> >
>> >> > I have created a control with some buttons an alphabet. When one
>> >> > of
>> >> > these
>> >> > buttons are pressed it posts back and in the postback event for
>> >> > the
>> >> > button
>> >> > pressed a list of tems is created with a list of buttons next to
>> >> > them
>> >> > to
>> >> > delete the term. My problem is that the delete button has a
>> >> > delete
>> >> > event
>> >> > attached to it but t does not fire. Is this because the delete
>> >> > butons
>> >> > are
>> >> > created in the postbaclk event and not the CreateChildControls
>> >> > method -
>> >> > and
>> >> > if so how do I fix this.
>> >> >
>> >> > Jim
>> >>
>> >>
>> >>
>>
>>
>>


Dec 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aymer | last post by:
i created a new button object. how do i attach an event on it? thanx for your help. Dim cc As ColorConverter = new ColorConverter() Dim b = new button() b.ID = "SelectedDate" b.BorderStyle...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
4
by: joe.osowski | last post by:
I've been staring at this a while, and I haven't had much luck with it. So I figure I'll try Usenet. No matter what I try, it seems the event.button property is always "0". Here is my test...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
1
by: Martin | last post by:
Hi, I have produced a custom server control that simple outputs a row of 26 buttons, one button for each letter of the english alphabet. now what I would like to do is catch the button click...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
3
by: =?Utf-8?B?Rmxhc2hwcm8=?= | last post by:
i have googled this question but cannot find an answer. i'm running windows vista and i'm using Visual Basic Express 2008. i know the build event button SHOULD be in under the compile tag but i...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.