473,800 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ 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.Respons e.Redirect("htt p://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.But ton

Private Sub MyButton_Click( ByVal sender As Object, ByVal e As
System.EventArg s)
Context.Respons e.Redirect("htt p://www.google.com" )
End Sub

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

Protected Overrides Sub CreateChildCont rols()
AddHandler MyButton.Init, AddressOf MyButton_Init
AddHandler MyButton.Click, AddressOf MyButton_Click
MyBase.Controls .Add(MyButton)
MyBase.CreateCh ildControls()
Me.ChildControl sCreated = True
End Sub

End Class

Nov 14 '06 #1
1 1957
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_C lick(object sender, EventArgs e)
{
OnDynButton1_Cl ick(e);
}
protected void OnDynButton1_Cl ick(EventArgs e)
{
if (DynButton1 != null)
DynButton1(this , e);
}
(Page that is using User Control)
protected override void OnInit(EventArg s e)
{
YourUserControl ID.DynButton1 += new EventHandler(Dy nButton1);
}
private void DynButton1(obje ct 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.goo glegroups.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.Respons e.Redirect("htt p://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.But ton

Private Sub MyButton_Click( ByVal sender As Object, ByVal e As
System.EventArg s)
Context.Respons e.Redirect("htt p://www.google.com" )
End Sub

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

Protected Overrides Sub CreateChildCont rols()
AddHandler MyButton.Init, AddressOf MyButton_Init
AddHandler MyButton.Click, AddressOf MyButton_Click
MyBase.Controls .Add(MyButton)
MyBase.CreateCh ildControls()
Me.ChildControl sCreated = 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
6826
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 rather than actually clicking the search button, but this does not run the search code behind the button.
11
13963
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 all users (btnSendAll). When user hits enter, I also simulate the effect of clicking button (btnSend). However, what I found btnSend doesn't fire (unless I click on the button). The postback function I call is as follows: function...
1
1804
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 handler to the click event. When a button is clicked, the background-color is set to blue. Try running the page, and clicking the "Do stuff and update controls
3
8832
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 twice, once with postback true, and second time without postback. This only happens for this button. How can I sort out this issue, any clues what to look for to get this sorted please. <p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
5
5433
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
8157
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 if I could place a hidden button in a frame that would have the attribute to refresh the other. I would need code to "invoke" the onclick event (ie i need code to click the button). is this possible? thanks.
6
2810
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) ... something like button2.click ??? Thanks for help ..
7
6871
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, it is not work, anyone can tell how to use button click event ? Thanks in advance, Martin
9
2749
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 affecting this. But I'm stuck. My handler is in C# code and the code looks right. But absolutely nothing happens when I click the button. protected void Button1_Click(object sender, EventArgs e)
1
7030
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 page has multiple button such login page with a search function somewhere around, then it's not respond properly. I have attached a brief example of two text boxes and two button. When ever a key is press on textbox one, I want to trigger...
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2945
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.