Why Event Bubbling And Why Not Directly Subscribe The Click Event
Jul 2, 2010
I was going through an article on event bubbling in asp.net and came to know that although it is possible to subscribe to the click event of a user control's button from the containing page, "doing so would break some of the object oriented rules of encapsulation". A better idea is to publish an event in the user control to allow any interested parties to handle the event.
My question is that exactly how does a direct subscription to the button's click event from a containing page would break the object oriented rules of encapsulation?
View 2 Replies
Similar Messages:
Apr 6, 2010
For test purposes I have created a simple button control that extends CompositeControl. I am able to place it on the page with a <asp:Content... and the Click event Bubbles without problem from the Control.
Now, here is the problem I am facing Due to design requirement I need to read the assembly and the classname from a table and dynamically create the control and add it to the <asp:Content. And when I do that the click event will not fire! Where am I going wrong.
Here is the code in the ButtonControl.cs
namespace Reports.Web.ServerControls {
[DefaultProperty("Text")]
[ToolboxData("<{0}:ButtonControl runat=server></{0}:ButtonControl>")]
public class ButtonControl : CompositeControl {
protected override void CreateChildControls() {
Button btn = new Button();
[Code]....
View 3 Replies
Aug 30, 2010
i can use javascript setInterval() (in combination with jquery ajax) to 'poll' the controller action in order to determine if something 'new' should be renedered onto the page. However, I'm not a huge fan of polling, especially when client browsers can be left unattended and are uneccessarily polling for changes.
Multiply that by the number of potential client machines that could be browsing the app and you get a feel for the scale of the issue with this approach. Now, in truth, this is EXACTLY the approach that I use to refresh certain page fragments on some ('read' - MANY!!) of my existing sites.
However, I'd like to know what the options are for subscribing in 'reverse' to events and having the controller 'know' about the client browser and any events that it is subscribed to and the controller then 'push' out the update to the client on a 'needs must' basis. Is this something that happens outside of the normal desktop events scenario?
View 2 Replies
Mar 1, 2010
how to go about retrieving data from another control by subscribing to an even and receiving back results at a later time. I'm trying to see if there is a way to have one web control (Main control), subscribe to an event in another web control (Search control), by maybe only sending in a method within the main web controls class. Once a query event occurs (via Button click) in the search web control, it sends back results to that original function in the Main Web Control (returning a datatable)
I think the goal is to have the search control be unaware of the main control and any specific methods or classes. Only have classes subscribe it it. Kind of like a top down process only. Is there any method that can work to accomplish this? I've looked into delegate methods and EventHandler (EventArgs) methods, but can't clearly see how this could apply.
View 4 Replies
Mar 17, 2011
in my ASP page iam using button and drop down list controls. In the button click event i have some process, and dropdown list change event have some coding. while iam clicking the button its not directly goto button click event, its going to dropdown list click event.
View 3 Replies
Mar 22, 2010
I've found posts about making a click event with jQuery for a button, however I need a little more then that. When any postback occurs on a page, I need to fire off a jQuery click event. Based on a condition, I want to continue processing (including running the server-side event code after the jQuery code), or, perform a redirect. I'm not quite sure how to go about this.
View 1 Replies
Jan 8, 2010
Private Sub control1 click event
& another protected sub control 2 click event
i need to call control1 click event in protected sub control 2 click event
View 1 Replies
Nov 17, 2010
i am currently developing an asp.net project. there is a previous, next, and cancel button that the user can utilize, but the problem is that everything is broken into controls so that if they hit the browser's back button it will reset everything and take them to the very beginning. i would like to capture the onbeforeunload event and trigger the previous button click event (i.e. treating navigation like clicking the previous button).
View 6 Replies
Sep 29, 2010
I got an event handler like this, in this event, i wanted to call another button click event. How can I do that?
[Code]....
if (ds.Tables[0].Rows.Count == 0)
View 3 Replies
Dec 28, 2010
i have an form with an button and some input controls. some time due to input problem i may get error after that if i refreshed the page then that time the button click event has fired, how to avoid this kind of bad event fire.
View 3 Replies
Feb 18, 2011
I have a textbox with autopostback=true and a button to save the data in the form. Functionality works fine when entering a value in the textbox, tabbing out of the textbox and clicking on the save button. But issue comes up when entering a value in the textbox and directly clicking on the save button without tabbing out of the text box. In the second scenario, only textchanged event fires and save click event dosen't fire. What I was expecting was after exection of textchanged event, save click event should also fire. But this is not happening.
View 5 Replies
Mar 1, 2011
I have a gridview called gvResults. In the gvResults_RowEditing event I add a row below the one selected. In that new row, which spans all columns, I insert a user-control. There are two buttons and some textboxes in the user control.
My problem is that when I click one of the user-control buttons it never gets to the button event handler, I think because the user control is not recreated on the page postback. How can I have the user-control events fire before the parent page events fire?
I tried using an update panel, but I still get the parent posting back before the user-control events.
View 3 Replies
Jun 25, 2010
I have searched around but unable to find a solution that will work. I have a link button that is created dynamically during the page load. It is given an ID (obviously). There is a script manager on the page. I have the controls added to a panel in the updatepanel (updatePanel1). There is a dynamic label that is also created with each link button. I can get a response from the linkbutton click event during a postback on the second time clicking the linkbutton, but I am getting a complete postback instead of the asyncpostback for that control. During the creation of the dynamic linkbuttons, I am also creating a dynamic trigger for each button and adding it to the updatePanel1. The Click event is not firing the method without doing a complete page postback.
View 4 Replies
Sep 24, 2010
I have write the code in .Net. When I click the Buttun then fired below event.
protected void ddldesignation_SelectedIndexChanged(object sender, EventArgs e)
{
Code.
}
View 1 Replies
Oct 5, 2012
I am updateing my gridview using button click event but at the fisrt time it does not get updated first time but its works second time i dont know why . Dol u know how to genterate two button click event for the same button.Records never get updated on first button click event but its works on second button click event.
View 1 Replies
Jul 13, 2010
I have one Button (Refresh Button), One ComboBox (containing DEV and UAT as its items) and a GridView on my asp page.
I am filling up my Grid with values from database on the ComboBox's 'TextChanged' event and Buttons's 'Click' event.
First time when page is loaded, there is no information in the grid, but when i choose DEV/UAT from the ComboBox 'TextChanged' event is fired, the grid is filled with the relevant data. That is what i want.
When i click the Refresh Button to refresh the data again, first comboBox's 'TextChanged' event and then 'btn_Click' event is fired.
I want then when a button id pressed only 'Click' event to be fired and not the ComboBox's 'TextChanged' event.
View 5 Replies
Sep 9, 2010
I am using fullCalendar and I'm able to populate the calendar with events very easily. And I undertsand the best way to add events to the calendar is through the database. What I need now is to catch and populate an edit event form after the user clicks an event.
View 1 Replies
Feb 9, 2011
i have written an button click event in js file but the event wasnt fired the code seems below
$("#btnSearch").click(function () {
debugger; alert("search button event fired");
$("#ctl00_MaintenanceContentHolder_btnSearch").click(function
ugger; alert("searchbutton event fired");
View 6 Replies
Oct 23, 2010
This event handler is not responding at all to the click event. On click, the pagination numbers disappear and I'm not able to trace it in the debugger because the event handle doesn't even fire so I have no idea what's going on.
[Code]....
View 2 Replies
Mar 4, 2010
Server control of VS.NET 2005 which have page load event and prerender event and other page events apart from there own.
View 2 Replies
Nov 26, 2010
In my user control I have gridview, and this grid is created programmatically, using Itemplate. In InstantiateIn methods I have this code.
Select Case _templateType
Case ListItemType.Header
Dim linkButton As New LinkButton [code]....
I want to wired up Click event to this LinkButton, and use this event in code behind.This is constructor of GridViewTemplate how implements ITemplate
Public Sub New(ByVal type As ListItemType, ByVal colname As String, Optional ByVal infoType As String = "")
'Stores the template type.
_templateType = type
'Stores the column na [code]....
and i have this call from user control:bfield.ItemTemplate = New GridViewTemplate(ListItemType.Item, dt.Columns(col).ColumnName, "label")
where is Dim bfield As TemplateField = New TemplateField()
View 2 Replies
Mar 29, 2011
I'm having trouble managing how to call upon databind from clicking on a row over an already populated repeater that will populate data regarding the row clicked TO another repeater on the same page.
I've succeeded doing that with postback, calling a jquery click event of that row, taking the data of the specific row and passing it onto a "Querystring" and after postpack, it will be pushed into a Session which the ObjectDataSource of the secondary repeater will recognize and populate the data tables accordingly.
The problem is, I must do it without a postback or in other words purely on client side.
View 1 Replies
Sep 14, 2010
I was wondering if there is a way to generate the event handler of a control directly in the markup view and not in the design view.
View 6 Replies
Sep 13, 2010
Below code, i need the RegularExpressionValidator on key press event/On change event. I need to validate same time while user doing input.
Code:
[code]....
View 5 Replies
Jul 6, 2010
i do not know what is going on my firefox!
my aspx and javascript codes are like this :
[code]....
when i type something in textbox 1,2,3 so i see just first alert (mean a,b,c).
View 1 Replies