Setting Properties-VBForums
Results 1 to 3 of 3

Thread: Setting Properties

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2017

    Setting Properties

    Here is the solution with code

    down vote
    i have a UC_Categories.ascx ( UC_1 ) which constraints categoryname . UC_Products.ascx ( UC_2 ) will show products by categoryname. Both of them are in a Page called BookShop.aspx ( Page )

    In the Page, when user click a UC_1 (step 1 ) , it will render a UC_2 by categoryname (step2 ). I process step 1 by sending a request with param that is categoryname to Page. Step2 create a new UC_2 ,set Properties value that is categoryname , and execute FillProductByCategoryName method. then add UC_2 to a PlaceHolder in the Page. but i don't show UC_2 .

    I need a help or suggest from everyone.

    Thank you for reading my question! ps : my english isn't very well.

    in the codebehind of the UC2 :
    public void FillProduct()
            ProductsMN productsMN = new ProductsMN();
            if (dlBook == null)
                dlBook = new DataList();
                dlBook.DataSource = productsMN.GetByCategoryName(CategoryName);
                dlBook.DataSource = productsMN.GetByCategoryName(CategoryName);
        public string CategoryName { get; set; }
    in the codebehind of the page
     protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
            string categoryName = Request.QueryString["categoryName"] as string;
            if (!string.IsNullOrWhiteSpace(categoryName))
                BookContent.Controls.Clear(); // BookContent : Placeholder
                Control c = Page.LoadControl("~/UC/UC_Books.ascx") as UC.UC_Books;
                UC.UC_Books ucBook = new UC.UC_Books();
                ucBook.CategoryName = categoryName;
                ucBook.FillProduct(); //line 10
                BookContent.Controls.Add(ucBook); //line 11
    at the PageLoad of the Page, useBook contains data. but in the Page (view ), i don't see data. i think //line11 isn't execute or not true .
    Last edited by Shaggy Hiker; Jul 11th, 2017 at 09:40 AM. Reason: Added CODE tags.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002

    Re: Setting Properties

    For anybody who reads this, I apologize for the subject line. The OP did NOT write that. The question got moved from a different location, since it appears to be ASP.NET, so I had to give it a subject line, and wasn't clear on what would be the best subject title for the question.
    My usual boring signature: Nothing

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Cebu, PH

    Re: Setting Properties

    Welcome to the forums!

    What happens if you add c to BookContent instead of ucBook?

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: My Blog | GitHub Repo | ASP Snippets |

    Rating someone's post is a way of saying Thanks...

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

Survey posted by VBForums.