473,500 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.Net Newbie question

Hi

I have been working through some basic samples and there is a problem with a
call to a button click

I am using Visual Studio 2008 and have placed a text box, a label and button
on a page - sample code here

<script language="C#" runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
lblSample.Text = txtSample.Text;
}
</script>

<form id="Form1" method="post" runat="server">
<P<asp:Label id="lblSample" runat="server"
Width="208px">Label</asp:Label></P>
<P<asp:Label id="Label1" runat="server" Width="104px">Enter Text
Here:</asp:Label>
<asp:TextBox id="txtSample" runat="server"></asp:TextBox></P>
<P<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button</P>
</form>

this submits the form but does not update the label.Text.

setting a break point in the button click never gets called

If however I transfer the code to the Page Load event it does get called.

Given that this is asample of a similar type in both a book and from a
seperate online tutorial it seems that I am doing something basically wrong.

TIA
H
Jun 27 '08 #1
3 1003
You should ask in the ASP .NET group.

Jun 27 '08 #2
you mite have not added the function to the click event.

try adding the following line to your form_load

Button1.Click+=new EventHandler( Button1_Click);
BigOldH wrote:
Hi

I have been working through some basic samples and there is a problem with a
call to a button click

I am using Visual Studio 2008 and have placed a text box, a label and button
on a page - sample code here

<script language="C#" runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
lblSample.Text = txtSample.Text;
}
</script>

<form id="Form1" method="post" runat="server">
<P<asp:Label id="lblSample" runat="server"
Width="208px">Label</asp:Label></P>
<P<asp:Label id="Label1" runat="server" Width="104px">Enter Text
Here:</asp:Label>
<asp:TextBox id="txtSample" runat="server"></asp:TextBox></P>
<P<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button</P>
</form>

this submits the form but does not update the label.Text.

setting a break point in the button click never gets called

If however I transfer the code to the Page Load event it does get called.

Given that this is asample of a similar type in both a book and from a
seperate online tutorial it seems that I am doing something basically wrong.

TIA
H
Jun 27 '08 #3
Double click on the button and see cursor, weather it goes to the
"Button1_Click" Handler method or it creates a new handler named
"Button1_Click_1"; if it creates a new handler then place code in the new
handler or simply remove the previous handler and then double click on the
button and paste code there.
--
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"BigOldH" wrote:
Hi

I have been working through some basic samples and there is a problem with a
call to a button click

I am using Visual Studio 2008 and have placed a text box, a label and button
on a page - sample code here

<script language="C#" runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
lblSample.Text = txtSample.Text;
}
</script>

<form id="Form1" method="post" runat="server">
<P<asp:Label id="lblSample" runat="server"
Width="208px">Label</asp:Label></P>
<P<asp:Label id="Label1" runat="server" Width="104px">Enter Text
Here:</asp:Label>
<asp:TextBox id="txtSample" runat="server"></asp:TextBox></P>
<P<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button</P>
</form>

this submits the form but does not update the label.Text.

setting a break point in the button click never gets called

If however I transfer the code to the Page Load event it does get called.

Given that this is asample of a similar type in both a book and from a
seperate online tutorial it seems that I am doing something basically wrong.

TIA
H
Jun 27 '08 #4

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

Similar topics

0
1565
by: Elger | last post by:
Dear Members, A newbie question How do I convert this XML example into HTML (using XSLT)? <DOCUMENT> <PARA> This <BOLD>is</BOLD> a <BOLD>test</BOLD> </PARA> </DOCUMENT>
4
1056
by: DragonLord | last post by:
I have a custom user control that i am trying to understand and it has numbers before the line items. So here it comes the real newbie question What the heck are the numbers for?? 205: For...
5
2488
by: kamikaze04 | last post by:
Hello. I have a very newbie question about Streams. The situation is that i have a function (that i cannot modify it's definition/call): public void F1(istream & in){ while( ...) { ...
5
1132
by: Banibrata Dutta | last post by:
Hi, I've gone through the list of "language differences" between 2.3 / 2.4 & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of CPython, and I consider myself still very very...
16
1854
by: Raxit | last post by:
Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy...
7
1502
by: idiolect | last post by:
Hi all - Sorry to plague you with another newbie question from a lurker. Hopefully, this will be simple. I have a list full of RGB pixel values read from an image. I want to test each RGB band...
5
2681
by: Randall | last post by:
I am a newbie trying to learn the DOM. Can someone tell me why the first alert statement returns null, and the second returns the value 33px (which was set using the style="top:33px;" in the DIV...
12
1813
by: Philipp.Weissenbacher | last post by:
Hi all! This is most certainly a total newbie question, but why doesn't the following code cause a segfault? void insertion_sort(int a, int length) { int i; for (i=0; i < length; i++) { int...
3
2330
Lokean
by: Lokean | last post by:
Sorry for this newbie question, this is not my realm of expertese. I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to...
5
1388
by: Dave | last post by:
I am new to Visual Web Developer 2005 Expres. I am using absolute positioning and every time I add a button control to my web form its width extends all the way to the edge of the page. IOW I...
0
7136
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
7018
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
7232
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...
1
6906
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...
0
7397
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
5490
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,...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.