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>
<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,