CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Join Date
    Jan 2010
    Posts
    130

    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
    Last edited by stephsh; May 18th, 2010 at 03:48 AM.

  2. #17
    Join Date
    Jan 2010
    Posts
    130

    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);
            }

  3. #18
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    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
    Last edited by JonnyPoet; May 18th, 2010 at 03:56 PM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  4. #19
    Join Date
    Jan 2010
    Posts
    130

    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?

  5. #20
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Disable specific button from set of programatically created buttons?

    Quote Originally Posted by stephsh View Post
    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. ???
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  6. #21
    Join Date
    Jan 2010
    Posts
    130

    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:
    <&#37;@ 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"...

  7. #22
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    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
    Last edited by JonnyPoet; May 31st, 2010 at 05:39 AM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  8. #23
    Join Date
    Jan 2010
    Posts
    130

    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;
                    }
                }

  9. #24
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Disable specific button from set of programatically created buttons?

    Quote Originally Posted by stephsh View Post
    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
    Last edited by JonnyPoet; June 1st, 2010 at 01:33 AM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  10. #25
    Join Date
    Jan 2010
    Posts
    130

    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?

  11. #26
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Disable specific button from set of programatically created buttons?

    Quote Originally Posted by stephsh View Post
    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.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured