473,480 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Button Click

Hello,

I am creating a custom control where I have a button.
Somehow my button click event is not being raised.
I tried to place different codes inside MyButton_Click and nothing
runs.
Then I added Context.Response.Redirect("http://www.google.com").
When I click the button postback is done but the page google is not
called.

I am on this for days. I looked everywhere in Google and everything
seems ok.

Could someone, please, tell me what to do to try to figure what is the
problem?

I don't know what else to try.

Thank You,
Miguel

Here is my code:
...
Public Class Contact
Inherits WebControl

Dim MyButton As New WebControls.Button

Private Sub MyButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Context.Response.Redirect("http://www.google.com")
End Sub

Private Sub MyButton_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
MyButton.ID = Me.ID & "_bSubmit"
MyButton.Text = "Submit"
End Sub

Protected Overrides Sub CreateChildControls()
AddHandler MyButton.Init, AddressOf MyButton_Init
AddHandler MyButton.Click, AddressOf MyButton_Click
MyBase.Controls.Add(MyButton)
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

Nov 14 '06 #1
1 1942
Is this a Custom Web Control or a Web User Control?

If this was a Web User Control I would do something like this:

(User Control Event Handler)
public event EventHandler DynButton1;
protected void btnDynButton1_Click(object sender, EventArgs e)
{
OnDynButton1_Click(e);
}
protected void OnDynButton1_Click(EventArgs e)
{
if (DynButton1 != null)
DynButton1(this, e);
}
(Page that is using User Control)
protected override void OnInit(EventArgs e)
{
YourUserControlID.DynButton1 += new EventHandler(DynButton1);
}
private void DynButton1(object sender, EventArgs e)
{
// Do something...
}

Sorry it's in C# I don't do VB.

Regaards,
Brian K. Williams
"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I am creating a custom control where I have a button.
Somehow my button click event is not being raised.
I tried to place different codes inside MyButton_Click and nothing
runs.
Then I added Context.Response.Redirect("http://www.google.com").
When I click the button postback is done but the page google is not
called.

I am on this for days. I looked everywhere in Google and everything
seems ok.

Could someone, please, tell me what to do to try to figure what is the
problem?

I don't know what else to try.

Thank You,
Miguel

Here is my code:
...
Public Class Contact
Inherits WebControl

Dim MyButton As New WebControls.Button

Private Sub MyButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Context.Response.Redirect("http://www.google.com")
End Sub

Private Sub MyButton_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
MyButton.ID = Me.ID & "_bSubmit"
MyButton.Text = "Submit"
End Sub

Protected Overrides Sub CreateChildControls()
AddHandler MyButton.Init, AddressOf MyButton_Init
AddHandler MyButton.Click, AddressOf MyButton_Click
MyBase.Controls.Add(MyButton)
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

Jan 16 '07 #2

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

Similar topics

5
6799
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
11
13843
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
1
1786
by: Klaus Jensen | last post by:
Hi! This has been annoying me all day, and I can't get it to work It is really driving me nuts! Basicly this simple webapp created to illustrate my problem, renders five buttons, and adds a...
3
8703
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
5
5403
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
21
8115
by: Ben | last post by:
Hello I have frames set up in an asp.net application and need one frame to refresh another. Seeing as events need to be registered at the time the page is sent from the server, I was wondering...
6
2796
by: user | last post by:
Hello, With ASP.NET2, how to program a button's click ? For example, I have two button and when i click the first one, i would like that the second one will be click too (by programming) ......
7
6842
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
9
2725
by: Jonathan Wood | last post by:
Does anyone know of any reason a button on a master page would have no effect? I have a complex HTML page that I'm converting to ASP.NET, and acknowledge I could have something odd that is...
1
6957
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
0
6915
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
7097
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
6750
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
6993
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
5353
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
3003
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...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.