473,386 Members | 1,702 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,386 software developers and data experts.

Adding Events / Page_Load / Designer Removing it

Hello

I have the following problem. I have an aspx Page. This page contains an
ASP-Table Object. So in that table, I have a linkbutton. So, I can't edit
the event of that button trough the WYSIWYG editor, so I co to the
CodeBehind and add the Event in the InitializeComponent() Method like this
this.lbTest.Click += new System.EventHandler(this.lbTest_Click);

so far, all works fine. now if i go to the WYSIWYG editor, add another
component to the page, that event will be removed and I have to add it
again.

Anyone an idea how I can force VS.NET not to remove that event??

Thanks

Patrick
Nov 18 '05 #1
5 1620
Its a bad idea to add code to InitializeComponent as it is
being generated by VS.NET and will get rewritten if you
make any change in the Visual Designer.

You can add Click Events by either Double Clicking your
Link Button in the Designer view or go to Properties
Window for that Link Button and click on Events Icon. Now
give a name to the Click Event of that button.

Thanks,
-Shan
-----Original Message-----
Hello

I have the following problem. I have an aspx Page. This page contains anASP-Table Object. So in that table, I have a linkbutton. So, I can't editthe event of that button trough the WYSIWYG editor, so I co to theCodeBehind and add the Event in the InitializeComponent() Method like thisthis.lbTest.Click += new System.EventHandler (this.lbTest_Click);
so far, all works fine. now if i go to the WYSIWYG editor, add anothercomponent to the page, that event will be removed and I have to add itagain.

Anyone an idea how I can force VS.NET not to remove that event??
Thanks

Patrick
.

Nov 18 '05 #2
yes, but I cannot doubleclick the linkbutton when it is for example in an
asp:table ...
"Shan" <an*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:03****************************@phx.gbl...
Its a bad idea to add code to InitializeComponent as it is
being generated by VS.NET and will get rewritten if you
make any change in the Visual Designer.

You can add Click Events by either Double Clicking your
Link Button in the Designer view or go to Properties
Window for that Link Button and click on Events Icon. Now
give a name to the Click Event of that button.

Thanks,
-Shan
-----Original Message-----
Hello

I have the following problem. I have an aspx Page. This

page contains an
ASP-Table Object. So in that table, I have a linkbutton.

So, I can't edit
the event of that button trough the WYSIWYG editor, so I

co to the
CodeBehind and add the Event in the InitializeComponent()

Method like this
this.lbTest.Click += new System.EventHandler

(this.lbTest_Click);

so far, all works fine. now if i go to the WYSIWYG

editor, add another
component to the page, that event will be removed and I

have to add it
again.

Anyone an idea how I can force VS.NET not to remove that

event??

Thanks

Patrick
.

Nov 18 '05 #3
here an example what i mean

<asp:table runat=server>
<asp:tablerow runat="server">
<asp:tablecell runat="server">
<asp:linkbutton runat=server id=lbTest>Test</asp:linkbutton>
</asp:tablecell>
</asp:tablerow>
</asp:table>

now try to add the event to the linkbutton using the Visual Designer :-)
when I try to click the button, it activates the table and adds the events
for the tables ... but how can i access that button? :-)
Nov 18 '05 #4
Interesting!

I was under the impression we were talking of HTML Table
Tags ! Sorry for the confusion.

I did look into it and yes there was no way to access the
controls!!It only allows us to add the Table Events in
Designer View...

I tried to add rows/cols programatically and it worked !

So I did some research and this is what MSDN say on the
Table Control ..

****
The Table control allows you to build an HTML table and
specify its characteristics in a straightforward manner. A
table can be built at design time given some static
content, but the power of a Table Web server control is
often realized when the table is built programmatically
with dynamic contents.
****

Source : http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfsystemwebuiwebcontrolstablememberstopic.
asp

As mentioned above Table Control is more powerful when it
is built programatically.

This is wat I did ... I placed a Table control in the form
and then programatically added rows/cols and a Button
Control ! I was able to write a Click Event for the button
control and associate the Event with the Button and was
able to access it and it did work!

Here is a gist of wat I did,

private void Page_Load(object sender, System.EventArgs e)
{
TrTest = new TableRow();
TcTest = new TableCell();
btnTest = new Button();
TcTest.Controls.Add(btnTest);
TrTest.Cells.Add(TcTest);
TblTest.Rows.Add(TrTest);
btnTest.ID = "Test";
btnTest.Text = "Test Button";
btnTest.Click += new System.EventHandler
(this.btnTest_Click);
}

private void btnTest_Click(object sender,System.EventArgs
e)
{
Response.Write("It Works!");
}
HTH

Thanks,
-Shan

-----Original Message-----
here an example what i mean

<asp:table runat=server>
<asp:tablerow runat="server">
<asp:tablecell runat="server">
<asp:linkbutton runat=server id=lbTest>Test</asp:linkbutton></asp:tablecell>
</asp:tablerow>
</asp:table>

now try to add the event to the linkbutton using the Visual Designer :-)when I try to click the button, it activates the table and adds the eventsfor the tables ... but how can i access that button? :-)
.

Nov 18 '05 #5
yes, i know that that works like this. But same Happens with Placeholders
etc :-) so it's not only a table-problem. but I found a solution - I add my
events to the OnInit-Code. The Visual Designer does not modify that one. so
it works now :-)

Patrick
"Shan" <an*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:0b****************************@phx.gbl...
Interesting!

I was under the impression we were talking of HTML Table
Tags ! Sorry for the confusion.

I did look into it and yes there was no way to access the
controls!!It only allows us to add the Table Events in
Designer View...

I tried to add rows/cols programatically and it worked !

So I did some research and this is what MSDN say on the
Table Control ..

****
The Table control allows you to build an HTML table and
specify its characteristics in a straightforward manner. A
table can be built at design time given some static
content, but the power of a Table Web server control is
often realized when the table is built programmatically
with dynamic contents.
****

Source : http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfsystemwebuiwebcontrolstablememberstopic.
asp

As mentioned above Table Control is more powerful when it
is built programatically.

This is wat I did ... I placed a Table control in the form
and then programatically added rows/cols and a Button
Control ! I was able to write a Click Event for the button
control and associate the Event with the Button and was
able to access it and it did work!

Here is a gist of wat I did,

private void Page_Load(object sender, System.EventArgs e)
{
TrTest = new TableRow();
TcTest = new TableCell();
btnTest = new Button();
TcTest.Controls.Add(btnTest);
TrTest.Cells.Add(TcTest);
TblTest.Rows.Add(TrTest);
btnTest.ID = "Test";
btnTest.Text = "Test Button";
btnTest.Click += new System.EventHandler
(this.btnTest_Click);
}

private void btnTest_Click(object sender,System.EventArgs
e)
{
Response.Write("It Works!");
}
HTH

Thanks,
-Shan

-----Original Message-----
here an example what i mean

<asp:table runat=server>
<asp:tablerow runat="server">
<asp:tablecell runat="server">
<asp:linkbutton runat=server

id=lbTest>Test</asp:linkbutton>
</asp:tablecell>
</asp:tablerow>
</asp:table>

now try to add the event to the linkbutton using the

Visual Designer :-)
when I try to click the button, it activates the table

and adds the events
for the tables ... but how can i access that button? :-)
.

Nov 18 '05 #6

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

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
6
by: Mark | last post by:
I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are...
5
by: Steven ONeil | last post by:
I'm trying to process the Onclick event of my page but it's never working. The button is dynamical added to the sites MainPanel. If I click the button on the page the Page_Load Event() is...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
3
by: michael_vanommeren | last post by:
I have two web applications that I am working with and I am trying to do a Response.Redirect from one to the other. They are setup as separate web applications on the same IIS server. If I go...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
1
by: 12jumper | last post by:
Hi All :) I've created an UserControl, which has a couple of properties that are collections (generic lists of some objects). It would be nice, if control refreshed each time I add a new item to...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.