Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a page where I can input multiple "orders" on one "invoice". I have three types of orders and each type can be on the invoice multiple times. Right now I write a separate aspx page for each type of order. something like this:

order1.aspx, order2.aspx, order3.aspx are very similar to this:

<form id="order1" runat="server" class="order1">
    <asp:Label ID="lblOrder1" runat="server" for="txtOrder1"><b>From:</b></asp:Label>
    <asp:TextBox runat="server" type="text" ID="txtOrder1" name="txtOrder1" class="order1"/>
</form>

On the main page, I can click one of 3 buttons to add an order type, with jQuery:

$('#btnOrder1').click(function () { $("#col3").append($("<div>").load("order1.aspx"));});

When I click the order button, it loads up the order form on the page. If I click it again, it loads another. This works fine.

When I click the save button on the invoice page, I need to fill the order objects(three objects, each representing a different type of order) with the values from the correct order and then save it to a database. I have the database saving code done, but I don't know how I can cycle through each order form on the page to fill in the appropriate object. I also need to be able to compare the different instances of each order, so I can check that the dates filled in on the order are not conflicting but I suspect I will be able to do this when I fill the object.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Your cycle is being messed due to the page-life cycle, and probably due to accesibility or events from objects appended to the DOM. (And probably due to multiple jquery functions and scripts loaded from each page).

Please, take a look at UserControls http://www.codeproject.com/Articles/1739/User-controls-in-ASP-NET

Instead of having one ASPX page for each type, you could have a "UserControl" per type. After doing that, you could consider having only 1 usercontrol with some parameters to manage the OrderType.

share|improve this answer
    
Thank you for leading me in the right direction. –  NiteTrip yesterday
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.