Results 1 to 4 of 4

Thread: Aspx Controls and Dynamic Loading With Events

  1. #1

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Aspx Controls and Dynamic Loading With Events

    Hello

    Need some help with this page that I'm creating.

    I have a page, that receives a List of Orders, for each order i need to load a user control. In the user controls I have a table, and for each order detail i add a row to the table, where I have several cells and 3 buttons, increase and decresae quantity and a remove line. So everything is created dynamic...

    The logic that i'll try to implement, with some sample data (class in project, not normalized):

    1 - Main page - Page Load - not postback -> use a Prop with ViewState to store the data;
    2 - Main page - Page Load - Linq to get the number of different orders in the Prop. And for each different order, create a new UC with the help of the function Page.LoadControl(Asxc_Path), and pass the filtered list (order of the loop), into a Prop of the user control
    3 - User Control - Load - Get the prop and for each order line, create a table row, with buttons and set the handlers for the click events.

    I think everything works with the exception of the click events, after some reading in MSDN, i get the felling that the click events are lost... So i read about the OnInit event of the user control, to create the controls, but i think that at this point i don't have access to the UC props, so i don't have a list to loop.

    So, my question, what should i do to handle this situation, or how to know the list in the OnInit, not using session vars?

    Thanks

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Aspx Controls and Dynamic Loading With Events

    I think everything works with the exception of the click events, after some reading in MSDN, i get the felling that the click events are lost... So i read about the OnInit event of the user control, to create the controls, but i think that at this point i don't have access to the UC props, so i don't have a list to loop.
    Perhaps you can add code to the post so as to determine where the issue occur.

    - kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

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

  3. #3

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Aspx Controls and Dynamic Loading With Events

    Thanks KGComputers

    I didn't have code at the time... Now i have code, but I'm facing a different "problem at this time".
    I have this "layout" a simple page with a User Control, the UC has a GridView inside an Update Panel, inside the gridView i have buttons to increase/decrease quantities and delete row.

    The events order after clicking one of the buttons, is Page Load, User Control Load, Click Event, so the underlying data it's updated after the UI is "ready", if i let the code like this, the data in the UI it's behind one refresh...

    So, what are my options, to refresh the data in the screen:

    - In this case, GridView, i can set the datasource again and call the DataBind?
    - It's a user control can i force an update?
    - Define a event in the UC subscrive in the Page, and for each change in the data, rise the event, and when handling force a page refresh?
    - Just delete everything and use JQuery?

    Thanks
    Last edited by mickey_pt; Nov 3rd, 2017 at 10:22 AM. Reason: Forgot to mention Update Panel

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Aspx Controls and Dynamic Loading With Events

    Normally, you can incorporate jQuery/Ajax functionality to handle that situation such as button events. Then again, you mentioned it's inside the update panel, have a look at this link Using the ASP.NET UpdatePanel Control with User Controls. I do have a project before utilizing UpdatePanels. I forgot if the concept provided in the link was integrated in our project.

    - kgc
    Last edited by KGComputers; Nov 7th, 2017 at 01:06 PM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

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

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