473,652 Members | 3,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not able to wire events in user control

I am trying to add a basic user control to a web site; coming from
visual
studio 2003 this was extremely easy. I would just add the user
control and
then add the controls that I want on that user control, but I am not
able to
get a basic link button to click. This seems so ridiculously basic,
but I am
not able to get this to work. What am I missing?

Apr 5 '07 #1
2 1641
Can you be more specific and give us some sample code? I can guarantee that
it's just as easy (and in some cases easier) in VS2005. What you're doing
works....so something else is broken.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
<jf******@tcime x.comwrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
>I am trying to add a basic user control to a web site; coming from
visual
studio 2003 this was extremely easy. I would just add the user
control and
then add the controls that I want on that user control, but I am not
able to
get a basic link button to click. This seems so ridiculously basic,
but I am
not able to get this to work. What am I missing?

Apr 5 '07 #2
On Apr 5, 2:37 am, "Ben Rush" <kwen...@yahoo. comwrote:
Can you be more specific and give us some sample code? I can guarantee that
it's just as easy (and in some cases easier) in VS2005. What you're doing
works....so something else is broken.

--
~~~~~~~~~~~
Ben Rushhttp://www.ben-rush.net/blog

<jfoll...@tcime x.comwrote in message

news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
I am trying to add a basic user control to a web site; coming from
visual
studio 2003 this was extremely easy. I would just add the user
control and
then add the controls that I want on that user control, but I am not
able to
get a basic link button to click. This seems so ridiculously basic,
but I am
not able to get this to work. What am I missing?- Hide quoted text -

- Show quoted text -
Here is the code:

using System;
using System.Data;
using System.Configur ation;
using System.Collecti ons;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using CustomDesignCab inetry.Componen ts;

public partial class controls_Kitche nCabinetOrderFo rm :
System.Web.UI.U serControl
{
string lnkHref = "javascript:Ope nBrWindow('%Kit chenPage
%','winFaq','to olbar=no,locati on=no,status=no ,menubar=no,scr ollbars=yes,res izable=no','Kit chenPageHeight' ,'KitchenPageWi dth','true');";

public int KitchenID
{
get { return int.Parse(this. lblKitchenID.Te xt); }
set
{
lblKitchenID.Te xt = value.ToString( );
LoadKitchen();
}
}
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck) SetItemsVisibil ity();

}

void lnkShow_Click(o bject sender, EventArgs e)
{
this.SetItemsVi sibility();
}

private void SetItemsVisibil ity()
{
this.lnItems.Vi sible = !this.lnItems.V isible;
//if (this.lnItems.V isible)
// lnkShow.Text = "(hide)";
//else
// lnkShow.Text = "(show)";
}

private void LoadKitchen()
{
CustomDesignCab inetry.Componen ts.Kitchen kit = new
Kitchen(GlobalI nfo.ConnString) ;
kit.RetrieveKit chenInfo(this.K itchenID);
string tmp = this.lnkHref;
tmp = tmp.Replace("%K itchenPage%", kit.KitchenPage );
tmp = tmp.Replace("Ki tchenPageHeight ",
kit.KitchenPage Height.ToString ());
tmp = tmp.Replace("Ki tchenPageWidth" ,
kit.KitchenPage Width.ToString( ));
this.lnkKitchen .HRef = tmp;
this.imgKitchen Door.Src = "../images/" + kit.DisplayImag e;

DataSet ds =
kit.RetrieveKit chenCabinetsFor OrderForm(this. KitchenID,
GlobalInfo.Curr entOrderID);
this.grdKitchen Brand.DataSourc e = ds;
this.grdKitchen Brand.DataBind( );
bool FoundSaleItem = false;
foreach (DataRow dr in ds.Tables[0].Rows)
{
if(!dr.IsNull(" Sale_Price"))
if (decimal.Parse( dr["Sale_Price "].ToString()) 0)
{
FoundSaleItem = true;
break;
}
}
grdKitchenBrand .Columns[5].Visible = FoundSaleItem;
this.lnkBrand.T ext = new
Brand(kit.ConnS tring).GetBrand Name(kit.BrandI D);
}

protected void lnkBrand_Click( object sender, EventArgs e)
{
this.SetItemsVi sibility();
}
}
Here is the HTML:

<%@ Control Language="C#" AutoEventWireup ="true"
CodeFile="Kitch enCabinetOrderF orm.ascx.cs"
Inherits="contr ols_KitchenCabi netOrderForm" %>
<table cellpadding="0" cellspacing="0" border="0" width="100%"><t r><td
colspan="2" align="left"><a sp:Label ID="lblKitchenI D" runat="server"
Text="0" Visible="False" ></asp:Label>
<asp:LinkButt on ID="lnkBrand" runat="server" Font-Bold="True" Font-
Names="Verdana" ForeColor="#FFE 3A9" OnClick="lnkBra nd_Click">Brand </
asp:LinkButton> &nbsp;
<asp:LinkButt on ID="lnkShow" runat="server" Font-Names="Verdana" Font-
Size="X-Small"
ForeColor="#FFE 3A9">(show)</asp:LinkButton>
</td></tr>
<tr id="lnItems" runat="server" valign="top"><t d width="20%" >
<a
href="javascrip t:OpenBrWindow( 'k5.htm','winFa q','toolbar=no, location=no,sta tus=no,menubar= no,scrollbars=y es,resizable=no ','798','585',' true');"
runat="server" id="lnkKitchen" >
<img border="0" src="../images/k5.jpg" width="129" height="197"
align="right" id="imgKitchenD oor" runat="server"/></a>
</td><td width="80%">
<asp:GridView ID="grdKitchenB rand" runat="server"
AutoGenerateCol umns="False" ForeColor="#FFE 3A9" Width="100%" >
<Columns>
<asp:BoundFie ld DataField="Kitc hen_Cabinet_ID"
HeaderText="Kit chen_Cabinet_ID " Visible="False" />
<asp:BoundFie ld DataField="Cabi net_Type_Name"
HeaderText="Typ e" />
<asp:HyperLinkF ield
DataNavigateUrl FormatString="I temNumHelp.aspx ?Item_Num={0}"
DataTextField=" Item_Num"
HeaderText="Ite m Num">
<ControlStyle Font-Names="Verdana" Font-
Size="Smaller" ForeColor="#FFE 3A9" />
</asp:HyperLinkFi eld>
<asp:BoundFie ld DataField="Reta il"
DataFormatStrin g="{0:C}" HeaderText="Ret ail" />
<asp:BoundFie ld DataField="Our_ Price"
DataFormatStrin g="{0:C}" HeaderText="Our Price" />
<asp:BoundFie ld DataField="Sale _Price"
DataFormatStrin g="{0:C}" HeaderText="Sal e Price" />
<asp:TemplateFi eld HeaderText="Qty ">
<ItemTemplate >
<asp:TextBox ID="txtQty" runat="server"
MaxLength="4" Width="32px">0</asp:TextBox>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
<RowStyle BackColor="#442 60E" />
<HeaderStyle BackColor="#755 A3D" />
<AlternatingRow Style BackColor="#5C4 000" />
</asp:GridView>
</td></tr>
</table>

I have tried adding like I would have found in VS2003:

override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.lnkBrand.C lick += new EventHandler(th is.lnkBrand_Cli ck);
this.lnkShow.Cl ick += new EventHandler(ln kShow_Click);
//this.Page.Load += new System.EventHan dler(this.Page_ Load);
}

I cannot get either lnkBrand or lnkShow to respond to click events.
This has got to be super smple, but I have been trying to figure it
out for a while.

TIA,

Apr 5 '07 #3

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

Similar topics

1
302
by: Daniel Billingsley | last post by:
If you double click on a control on a form in the designer it writes the handler stub and links it for what I guess is considered the "default" event of the control. Double-click on a form, for example, and you get a _Load() handler. The link is handled in the InitializeComponents() method, which the designer places in the "...generated code" region with the comments "... do not modify the contents of this method...". I know...
1
8155
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the first time the control is dynamically loaded, everything works fine. After that, if the control is loaded again from the page button event handler, the user controls events fail to fire on the first click NOTE: I (believe I) am rebuilding all...
2
4331
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control displaying the contents of the data source, whilst another control updates the datasource via a command buttons implementation of 'Click', an event raised in the 'Handle Postback Events' stage of the control execution life cycle (via the...
4
1747
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a specific process is done,, but the form which will host the user control has to specify what has to be done Something like this , if the event is fired it should call the event in
0
1838
by: Scott McChesney | last post by:
I have a problem I hope you folks can help me with. I have an application that is using a tab-based interface, with the ability for users to drag an item from a ListBox onto the tab control. This will create a new tab, put a new instance of the proper UserControl into the tab, and populate said UserControl with the data culled from the drop source. Because of the nature of this application, the particular UserControl that will be...
2
15444
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all events allowing the user control to react to the mouse click. Setting the Enabled property on the label to False comes close, but I don't want the font color to change. Does anyone have an idea how .NET implements the code behind the Enabled...
2
2377
by: Chu | last post by:
Thanks everyone for taking a moment to read this. I've got a page where I use a LinkButton and I wire up a dynamic event to the button. When the user clicks the button, the event is fired as expected. In the event code for that button, a new LinkButton is added to the page and is wired up to yet a different event, however when clicked, the page is posted back but the event is not triggered. I'm assuming it has something to do with the...
8
2000
by: MrNobody | last post by:
If I have a control like say a drop down list and I have some kind of onSelectItem change event, is there a way to temporarily suspend the event handling (without removing the event and then re-attaching it?) while I edit it's contents which would otherwise cause the event to fire? Or is there maybe a way in my event handler to tell if the user triggered it as opposed to the program itself?
2
1859
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for a windows application. I have a richtextbox control on my form that I make it readonly. 1. Do I need to make readonly to be false to append text to it? 2. Even though I chose the Cursor property of the richtextbox to be "No" but when I run the application I can still click on the RTB and got a Ibeam cursor among my text. Is there a way to prevent a user being able to click on the text and get the ibeam...
0
8367
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
8279
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
8811
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...
1
8467
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,...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
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.