Re: Disable specific button from set of programatically created buttons?
Thank you all very much for your comments! I'll have a read through and try those different methods out.... I have created an ASP.Net/C# Web Application in MS Visual C# V9.0 2008 and am thus using LinkButtons.
P.s. Steph is just my nickname, I'm actually female :P
Re: Disable specific button from set of programatically created buttons?
My event handler no longer fires... I tried deleting the whole page and creating a new one but no luck there...
Code:
protected void CreateSetOfLinklabels()
{
...
mLbtnPage.Click += new EventHandler(mLbtnPage_Click);
}
private void mLbtnPage_Click(object sender, EventArgs e)
{
LinkButton lb = sender as LinkButton; // Breakpoint not reached!
string id = lb.ID;
SData.miSelectedPage = int.Parse(id);
SelectLinkLabel(sender as LinkButton);
}
Re: Disable specific button from set of programatically created buttons?
Excuse my request but something is strange for me in the whole thing. But I normally don't do asp.net but C# Windows forms most times, so I'm really mnot very familar with asp.net and HTML pages.
As much as I know about HTML pages they all are created as a stream of text so how do you create your linkbuttons by use of code like you did? On the other hand you write that you have creted a new page, so whats the background here?
I remembered to a page containing a repeater and there we also had LinkButtons on it, but as much as I remember this was very challenging in that time and there was a property of the repeater which contains a wrong value and then the linkbuttons refused to fire. But this is more then 3 years ago so I really forgot how this worked and what in the end was the problem.
But a really dynamically created page is done totally other then you showed in your code as you really need to create the whole HTML text by code within all tags position commands and all that.
So please tell me, what is the purpose of your code and what is already working and what it fails to do. Also explain what sort of Control is 'holderpages' where you add your LinkButton
Re: Disable specific button from set of programatically created buttons?
Interesting!!
I have tried applying both your theories but strangely my event handler is no longer being fired (i didnt change the syntax at all)! Form posts state this problem can occur with Visual Studio and that it can sometimes be solved by deleting the ASP.NET page and then recreating it. I tried that but no luck there... Any ideas?
Re: Disable specific button from set of programatically created buttons?
Quote:
Originally Posted by
stephsh
Interesting!!
I have tried applying both your theories but strangely my event handler is no longer being fired (i didnt change the syntax at all)! Form posts state this problem can occur with Visual Studio and that it can sometimes be solved by deleting the ASP.NET page and then recreating it. I tried that but no luck there... Any ideas?
Sorry this doesn't answer to get informed about how you did the whole thing. What controls are you using on your page to be able t add some LinkButtons. ???
Re: Disable specific button from set of programatically created buttons?
My ASP.NET page contains the ASP.NET PlaceHolder control "holderPages". In my Code Behind page I programmed the PlaceHolder to be filled at run-time with a series of linklabels (post #17).
This is what my ASP.NET page looks like:
Code:
<%@ Page Title="MyPage" Language="C#" MasterPageFile="~/Input_master.Master" AutoEventWireup="true" CodeBehind="MyPage.aspx.cs" Inherits="MyProject.MyPage" %>
<asp:Content ID="ContentMain" ContentPlaceHolderID="ContentPlaceHolderMain" runat="server">
<div class="title">
MyPage
</div>
<asp:PlaceHolder ID="holderPages" runat="server"></asp:PlaceHolder>
<p>
<asp:Table ID="tblReportSelection" runat="server" CssClass="tblReportSelection">
</asp:Table>
</p>
</asp:Content>
On creating a linklabel button, the eventhandler "mLbtnPage_Click" is successfully added. On clicking on a linklabel the event is however not called. I debugged the whole code step for step multiple times and not once did it reach the mouse event function "mLbtnPage_Click"...
Re: Disable specific button from set of programatically created buttons?
Please zip the project and post it as I still cannot create a Page like you have. There are too much things undefined like why do you have selected Page and all that stuff
Re: Disable specific button from set of programatically created buttons?
On a similar page (named "MyPage") with an identical problem I inserted JonnyPoet's recommended method of searching through all controls for a LinkButton. Only one object is however displayed in the list of controls and that is MyPage! I think this problem stems from MyPage deriving from both a masterpage and a base page. How do I access the controls IN MyPage??
I tried using the method below but received a syntax error for "MyProject.MyPage.Controls":
Code:
foreach (Control c in MyProject.MyPage.Controls)
{
if (c is Button)
{
Button b = (Button)c;
b.BackColor = System.Drawing.Color.Red;
}
}
Re: Disable specific button from set of programatically created buttons?
Quote:
Originally Posted by
stephsh
On a similar page (named "MyPage") with an identical problem I inserted JonnyPoet's recommended method of searching through all controls for a LinkButton. Only one object is however displayed in the list of controls and that is MyPage! I think this problem stems from MyPage deriving from both a masterpage and a base page. How do I access the controls IN MyPage??
I tried using the method below but received a syntax error for "MyProject.MyPage.Controls":
As already told please zip the project and post it here so we can have a look on it what happens
Re: Disable specific button from set of programatically created buttons?
Firstly my project wont work without the related database and webservice and secondly I dont have permission to make my whole project public... :S
would it help if i would post a specific part of the project and if so which part?
Re: Disable specific button from set of programatically created buttons?
Quote:
Originally Posted by
stephsh
Firstly my project wont work without the related database and webservice and secondly I dont have permission to make my whole project public... :S
would it help if i would post a specific part of the project and if so which part?
Simple make a runable demoproject which shows exactly that part of code, where you actually have your problem.
That way we can debug ourself and see whats going on.