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
- 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,menubar=no,scrollbars=yes,resizable=no','KitchenPageHeight','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.KitchenID,
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>
<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','toolbar=no,location=no,status=no,menubar=no,scrollbars=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,