Web User Control - Button Click - does not fire event but just refreshes the page , but move the control to the bottom and it works!!

I have a web user control which is has one Button control on it. It has a event for handling the click... if I put this user control ( button ) at the top  of the page, the click event does not get fired just page is refreshed...but where as if I move to the bottom of the page, ButtonClick is fired ????

I am completely clueless why is this change of behavior with respect to the position of the control??

Thanks.

0
aspnetforumuserro
11/25/2008 7:23:27 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1923 Views

Similar Articles

[PageSpeed] 55
Get it on Google Play
Get it on Apple App Store

could you show us the code that you have problem with ...

0
GillouX
11/25/2008 7:35:57 PM

 

Here is the code ( i have taken out the unwanted part of the page )

Please note that the bSave does not work where as bSave1 works...

 Thanks.

 =======================================================================================================================

ProjWPRP.aspx 

<%@ Page Language="C#" MasterPageFile="~/TopMenuTemplate.Master" AutoEventWireup="true" CodeBehind="ProjWPRP.aspx.cs" Inherits="WPRP.Web.ProjWPRP" %>
<%@ register src="ucEditControl.ascx" tagname="ucEditControl" tagprefix="uc3" %>
<%@ register src="ucButtonControl.ascx" tagname="ucButtonControl" tagprefix="uc1" %>
<asp:content contentplaceholderid="Body" id="cProjWPRP" runat="server">
<br />
<p>
<uc1:ucbuttoncontrol id="bSave" runat="server" cssclass="stdbutton" label="Save"></uc1:ucbuttoncontrol>
&nbsp;&nbsp;
</p>
<br />
<table border="1" width="721">
   <tr>
     <td>
 <table border="0" width="720">
 <tr>
  <td width="200" valign="top" class="stdtextbold">Internal Notes</td>
         <td width="520">
         <uc3:uceditcontrol id="txtInternalNotes" enableviewstate="true" runat="server"></uc3:uceditcontrol>
  </td> 
 </tr>  
 </table>
     </td>
   </tr>
</table>
<br />
<p>
<uc1:ucbuttoncontrol id="bSave1" runat="server" cssclass="stdbutton" label="Save"></uc1:ucbuttoncontrol>
</p>
<br />                                                                    
</asp:content>

==============================================================================================

 

ProjWPRP.aspx.cs

 

protected void Page_Init( object sender, EventArgs e )
{

 //User control events
 this.bSave.ButtonClicked += new EventHandler( bSave_ButtonClicked );
 this.bSave1.ButtonClicked += new EventHandler( bSave_ButtonClicked );
}

 

============================================================

0
aspnetforumuserro
11/25/2008 8:39:24 PM
Reply:

Similar Artilces:

Single page with multiple user web controls VS Multiple page with specific user web controls
I have a question regarding single page with multiple user web controls vs multiple page with specific user web controls   Option 1: I am of the opinion to have multiple pages with specific user web controls and use an object to store all the information as the user navigates through the application. And finally at the end, read this object and save all the information to the backend database.   Option 2: My respected team member suggests that we have only one page, with all the specific user web controls and not use an object, instead show/hide the user web controls based ...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Web User Control not working on Web Page
I created a web user control to contain 3 grids and then used a span tag so that the window shows only one grid but can be vertically scrolled to show all three.  It works great on the control but when I drag the control onto a web page all 3 grids are displayed and the scroll bars are missing.  Does anyone have any suggestions for this or have run into this problem before.  Thanks........

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Web User Control DropDownlist Control Event not working..
Hi everybody,   I created a web user control and put this on a web application on same project. But the dropdownlist selectedindexchanged event is not working. That is first part of task, the next is to get the values of the dropdownlist of this user control to be used in web application. How could I fixed this problem? Thanks in advanced.User Control Private Months As String() = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}    Private Days1 As String() = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", ...

Event handling web user control buttom in web form
How would I handle the button1 click event from a web user control on a web form in the codebehind? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("test") End Sub does not work. Button1 is in the web user control. How would one handle the event in the page the web user control is embedded in? nevermind. it all came down to the class declaration in the codebehind file for the user control. It was originally webusercontrol2 and I renamed the ascx file to datesel.ascx and it never changed t...

Refresh Web form (parent) when submiting Web User Control
I got one Web form that contains one Web user control. The web form is displaying some data that is stored in database and Web User Control to edit this data and save the changes to database. When I press submit button in user control the data is getting stored in db, but Web form is not updated with this new changes ( i think this is because of the callback ). If I refresh the page then i see the changes. How can I make user control fire the refresh event in web form? If you have a answer pls give me a example or point to one tutorial, its much easier to understand! Thanks for your time! You have to rebind the controls after inserting new record and that should be done just after inserting new record. Mihir Solanki Hello, thank you for you reply, but like I said I prefer a example or tutorial that show me how to do this. I have worked with .net in just few months. So pls, give me a example or something i can learn from. Thanks! By the way, the data that is displayed in the web form is not DataBind to database. I display the data in custom way..I will maybe need to access the Web Form Page and then call the method that displays the data, but the problem is that i cant get access to this page from the Web User Control. I know that I can get the parent page by writing Page.Parent but then I should cast it to the Web Form ( named Default3 ) like this (Default3(Page.Parent)).displayDataMethod(); The problem is that Default3 is not known class in user control. ...

Click event available to web control within user control? How?
I have a main .aspx page.  I am using code behind, developing with Visual Studio Pro 2003.  I have a user control (.ascx) on my main page.  Inside that user control are web server controls (namely LinkButtons).  I want to have all the LinkButtons to point to one click event.  That click event will identify the LinkButton by its ClientID and perform an action accordingly.  Within the LinkButtons, do I type OnClick="myClickEvent"? Where (in what .vb file) do I put the click event and how do I point all the LinkButtons to fire it when clicked. If I doub...

Mulitple instances of a web user control not working on same web page
Hi,Can any body help me?I've developed one PopUp Calendar user control that has a textbox control and a link with javascript to open  a popup window to show the asp:calender control. When user select any date, it closes the popup window and update the textbox value with the selected date. And this is working absolutely fine.Here is the code:CalendarControl.ascx file content...---------------------------------- <%@ Control Language="VB" AutoEventWireup="false" CodeFile="CalendarControl.ascx.vb" Inherits="CalendarControl" %> <script language=javascript> function pickDate(...

How do you expose an event from a server control within an user control on an web form?
I have a calendar inside of an user control Simple.ascx The user control is sitting on my web form Simple.aspx. How do I access the VisibleMonthChanged event from my web form Simple.aspx? Is it possible? Yes Create Event in usercontrol which fires on page when VisibleMonthChanged event fires on usercontrol. Jigar Desai-----------------------Do not forget to "Mark as Answer" on the post that helped you. Ok, I created the event Public Event MonthChanged() in Simple.ascx.vb. Then I add the follow to Simple.aspx.vb Private Sub Simple_MonthChanged() Si...

Web User Control dynamically generated control events won’t fire.
I hope someone can give me a hand on this one.   This is what I am trying to do:   We need to create a report. We are using a Repeater control to generate a custom grid. The columns and data fields won’t be known until run-time.   I’ve created a WebUserControl which contains a repeater control.   At run-time, I dynamically create templates for the header and data items. On the header template I want to use a LinkButton so that data can be sorted when the user clicks on one of the header columns.   In my Header Template class, I have a reference to a list o...

Custom User Controls and dynamically created web controls events not firing
I have a peculiar problem and since I am just starting to use .net I am confident I am doing something wrong, but I can't see it and I've wasted a lot of time so far trying to figure it out. Hopefully one of you can figure it out. I have a custom User Control and I am dynamically creating a RadioButtonList. If I remove the custom user control from the page the RadioButtonList works as expected and correctly. However, once I add the custom control, it does not fire the SelectedIndexChanged event. Below is some code. If all I do is remove: "<UC:TOPMENU id="TopMenu1"...

Add user control from user control to web page
Hi there, I have a user control, that is inside another user control on a web page. From this user contfol, I need to add something to a place holder on the parent web page. I am having troubles referencing the placeholder correclty. I can get it fine as build time, but on runtime it kicks up the "Object reference not set to an instance of an object" error. Any ideas would be greatly appreciated. -------------------------------------------------------------- protected Civil_and_Corporate.candcadmin._default _default; ------------------------- Control objControl...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

Persisting data in a web user control, which contains a list of other web user controls.
 Hi All, I have a control I've created, which can have a number of child controls - also user controls - stored as an ArrayList, which can be added wither a design time or programmatically.My problem is when I add to the list programmatically, it doesn't persist them. So if I add 3 child controls in step 1 of a wizard, with the aim that those three will be visible inside the parent in step 3, what happens is that the parent has no child controls and the item count is 0.Can anyone help? Thanks in advance.Code:Parent Control Markup: <%@ Control Language="C#" Auto...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

How do I pass an "on click" event to the Web Page from a User Control?
Hello,   I was wondering if anyone can help me with this.  I have a button on a User Control. How do i get the "on click" event to pass between the UC and the web page? Or, better yet, how do I LEAVE the the On Click event code on the Web Page and just have the button be on the UC?   Thanks   JD   PS:  I'm using .NET 2.0 and C#  Any reason the onClick event can't be used from the user control?"Hokey religions and ancient weapons are no match for a good blaster at your side." The "On Click" event calls a f...

Master Page, Dynamically creating web user control and Event not firing
I am sure all of you have seen this article by Scott Allen. Great Article http://odetocode.com/Blogs/scott/archive/2006/04/12/3271.aspx In here I saw a comment Thursday, May 04, 2006 11:50 AM by Priya # re: The MasterPage Article I Thought I’d Never Finish Good one. I have a custom control with a button. The button click event fires if the page is without master. But, after the master is added, the event does not fire. Can you please help with this? Thanks a lot. Do any of you know what the answer to this problem is. I have a similar issue. Let me explain issue in detail. I have a master page called Test.master, just a blank page nothing in it.I have a Web user Control called rGridWUC.ascx file. In the control I have a very simple gridview (just 1 column called “Name”  and a link button called “Edit”).I have a web page called TestPageGridWUC.apsx, using Test.master page. In this page I dynamically create the rGridWUC twice.The issue is I am not able to catch the rGridView_RowEditing event when the edit link button in the grid view is clicked. I am loading the controls on both postback and first time in  as well. The code I have written works fine without the master page. But the moment I add the master page I cannot get the event to fire. Here is my Code =======================Test.Master aspx page===========================<%@ Master Language="VB" CodeFile="Test.master.vb" Inherits="Test" %> <!DOCTYPE html PUB...

Web user control inside update panel replace with another web user control
 Hi there. I have a page with a menu. an and then the content. My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control. In normal language. Is there a way that i can load one web user control into antoher and then disposose the original? Thanks in advance hello. well, what ...

Use Web Custom control or Web User control?
Friends,  I have a generic aspx page and its functions which is used in many .NET web application. The generic page contains a HTML Div control, server drop down list, server buttons, server textbox and it have different server and client functions to do its tasks for calling aspx pages in web applications. My problem is I do not know whether I should make that generic page as a web user control (but this is tedious because all other application folders must store frontpage aspx and code behind files of the generic page) or as a web custom control (This seems to be good beca...

change layout of web controls in web user control
Hi I have create a user control with 3 asp:textbox in it. I would like to reuse the same 3 textboxes in 2 seperate web pages. In one case I want them to appear in  a row (as search parameters) and in the other I want them to appear in a column(to add a new object)..  Can I do change layouts using CSS or something? Hi,    Here is a solution to your question for your reference. Create a web user control as the following <%@ Control Language="C#" AutoEventWireup="true" CodeFile="DynamicalUserControl.ascx.cs" Inherits="DynamicalUserControl" %><asp:Panel ID="...

Web resources about - Web User Control - Button Click - does not fire event but just refreshes the page , but move the control to the bottom and it works!! - asp.net.web-forms

Gogglebox refreshes the reality genre
As a new batch of old reality shows floods the network schedules, it's tempting to recall a time when unscripted TV held the promise of something ...

CIMB Australia refreshes top management team
Financial services provider appoints several new senior roles as Nick Rowe, Oscar Ludwigson depart.

Apple TV refreshes Events channel ahead of iPhone 6S announcement livestream
... on the Apple Events channel awaiting Apple TV users. Just hours before the iPhone 6S announcement kicks off in San Francisco, Apple has refreshed ...

Olson Refreshes Belize's Identity with a Fresh Take on Old Travel Posters
Check out the old identity for the country of Belize, and you're transported straight to the '80s, which figures since that's the last time the ...

Pepsi NEXT Refreshes the Taste Test With Web Parodies
Pepsi NEXT wants you to know it's savvy to the internets. It's already launched a TV ad featuring a break-dancing, guitar-shredding baby, created ...

After Launching Its First Mobile Game, AOL Refreshes Games.com
Games.com , a division of AOL, is relaunching today to go after one of this year’s biggest buzzwords: Cross-platform gaming. As it existed in ...

Alienware Refreshes Lineup With Laptop Updates, And Liquid Cooled X51 Desktop
Today Alienware announced some refreshes to its lineup. On the laptop front, the Alienware 13, 15, and 17 notebooks have been updated, and the ...


Viber launches desktop client, refreshes mobile app design
Popular cross-platform messaging and VOIP service Viber is introducing brand new desktop apps along with a complete refresh of its mobile apps ...

Google Refreshes Its Chromebook Pixel For 2015 With A 12-Hour Battery Life And USB Type C Charger: Core ...
Along with a fancy new hardware-focused Google Store, there's a shiny new version of the super-premium Chromebook. Google just threw the Chromebook ...

Resources last updated: 2/29/2016 7:52:24 PM