473,378 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1629
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******@tcimex.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.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...@tcimex.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.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.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CustomDesignCabinetry.Components;

public partial class controls_KitchenCabinetOrderForm :
System.Web.UI.UserControl
{
string lnkHref = "javascript:OpenBrWindow('%KitchenPage
%','winFaq','toolbar=no,location=no,status=no,menu bar=no,scrollbars=yes,resizable=no','KitchenPageHe ight','KitchenPageWidth','true');";

public int KitchenID
{
get { return int.Parse(this.lblKitchenID.Text); }
set
{
lblKitchenID.Text = value.ToString();
LoadKitchen();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) SetItemsVisibility();

}

void lnkShow_Click(object sender, EventArgs e)
{
this.SetItemsVisibility();
}

private void SetItemsVisibility()
{
this.lnItems.Visible = !this.lnItems.Visible;
//if (this.lnItems.Visible)
// lnkShow.Text = "(hide)";
//else
// lnkShow.Text = "(show)";
}

private void LoadKitchen()
{
CustomDesignCabinetry.Components.Kitchen kit = new
Kitchen(GlobalInfo.ConnString);
kit.RetrieveKitchenInfo(this.KitchenID);
string tmp = this.lnkHref;
tmp = tmp.Replace("%KitchenPage%", kit.KitchenPage);
tmp = tmp.Replace("KitchenPageHeight",
kit.KitchenPageHeight.ToString());
tmp = tmp.Replace("KitchenPageWidth",
kit.KitchenPageWidth.ToString());
this.lnkKitchen.HRef = tmp;
this.imgKitchenDoor.Src = "../images/" + kit.DisplayImage;

DataSet ds =
kit.RetrieveKitchenCabinetsForOrderForm(this.Kitch enID,
GlobalInfo.CurrentOrderID);
this.grdKitchenBrand.DataSource = ds;
this.grdKitchenBrand.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.Text = new
Brand(kit.ConnString).GetBrandName(kit.BrandID);
}

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

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="KitchenCabinetOrderForm.ascx.cs"
Inherits="controls_KitchenCabinetOrderForm" %>
<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td
colspan="2" align="left"><asp:Label ID="lblKitchenID" runat="server"
Text="0" Visible="False"></asp:Label>
<asp:LinkButton ID="lnkBrand" runat="server" Font-Bold="True" Font-
Names="Verdana" ForeColor="#FFE3A9" OnClick="lnkBrand_Click">Brand</
asp:LinkButton>&nbsp;
<asp:LinkButton ID="lnkShow" runat="server" Font-Names="Verdana" Font-
Size="X-Small"
ForeColor="#FFE3A9">(show)</asp:LinkButton>
</td></tr>
<tr id="lnItems" runat="server" valign="top"><td width="20%" >
<a
href="javascript:OpenBrWindow('k5.htm','winFaq','t oolbar=no,location=no,status=no,menubar=no,scrollb ars=yes,resizable=no','798','585','true');"
runat="server" id="lnkKitchen">
<img border="0" src="../images/k5.jpg" width="129" height="197"
align="right" id="imgKitchenDoor" runat="server"/></a>
</td><td width="80%">
<asp:GridView ID="grdKitchenBrand" runat="server"
AutoGenerateColumns="False" ForeColor="#FFE3A9" Width="100%" >
<Columns>
<asp:BoundField DataField="Kitchen_Cabinet_ID"
HeaderText="Kitchen_Cabinet_ID" Visible="False" />
<asp:BoundField DataField="Cabinet_Type_Name"
HeaderText="Type" />
<asp:HyperLinkField
DataNavigateUrlFormatString="ItemNumHelp.aspx?Item _Num={0}"
DataTextField="Item_Num"
HeaderText="Item Num">
<ControlStyle Font-Names="Verdana" Font-
Size="Smaller" ForeColor="#FFE3A9" />
</asp:HyperLinkField>
<asp:BoundField DataField="Retail"
DataFormatString="{0:C}" HeaderText="Retail" />
<asp:BoundField DataField="Our_Price"
DataFormatString="{0:C}" HeaderText="Our Price" />
<asp:BoundField DataField="Sale_Price"
DataFormatString="{0:C}" HeaderText="Sale Price" />
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:TextBox ID="txtQty" runat="server"
MaxLength="4" Width="32px">0</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#44260E" />
<HeaderStyle BackColor="#755A3D" />
<AlternatingRowStyle BackColor="#5C4000" />
</asp:GridView>
</td></tr>
</table>

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

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.lnkBrand.Click += new EventHandler(this.lnkBrand_Click);
this.lnkShow.Click += new EventHandler(lnkShow_Click);
//this.Page.Load += new System.EventHandler(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
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...
1
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...
2
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...
4
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...
0
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. ...
2
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...
2
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...
8
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.