Here's my situation:
I'm trying to develop a form that users will use to track sales opportunities. Its based on a VB6 application that makes heavy use of class modules to store and save information after its been editted, so I'm looking to build a similar system in ASP.NET.
I've been able to create the classes, but I'm unsure exactly how ASP.NET could use them and whether they can be altered within the page.
For example, I have a read only textbox which displays the customer name for an opportunity, with a link beside it to change the customer. Clicking the Change Customer link will open a pop-up window, where the user selects a customer from a list, clicks accept and it updates the textbox in the parent window with the name of the customer.
One option is to simply store the customer ID in a hidden field, then save that value to the database when the user saves the file. This I can handle. What I'd prefer to do though, is use the .Customer property of my Opportunity class to keep track of the customer ID, then use a class function to save the changes to the opportunity.
Here's some sample code I've been working with:
This works so far in that it loads up the customer ID into the objOpportunity.Customer property, but I need to be able to change the objOpportunity.Customer value to the new Customer ID from the pop-up window, then come up with a way to call a Save function within the objOpportunity class itself.
Is this possible to do, or would I be better off simply using hidden inputs to store the Customer ID, then saving the values of all the hidden inputs to update my database?
I'm trying to develop a form that users will use to track sales opportunities. Its based on a VB6 application that makes heavy use of class modules to store and save information after its been editted, so I'm looking to build a similar system in ASP.NET.
I've been able to create the classes, but I'm unsure exactly how ASP.NET could use them and whether they can be altered within the page.
For example, I have a read only textbox which displays the customer name for an opportunity, with a link beside it to change the customer. Clicking the Change Customer link will open a pop-up window, where the user selects a customer from a list, clicks accept and it updates the textbox in the parent window with the name of the customer.
One option is to simply store the customer ID in a hidden field, then save that value to the database when the user saves the file. This I can handle. What I'd prefer to do though, is use the .Customer property of my Opportunity class to keep track of the customer ID, then use a class function to save the changes to the opportunity.
Here's some sample code I've been working with:
Code:
<tr>
<td class="label1">Customer:</td>
<td class="label1">
<input id="CustomerID" readonly="readonly" type="hidden" runat="server" />
<input class="input1" id="lblCustomer"
readonly="readonly" type="text" runat="server" /></td>
<td class="label1">
<a href="javascript:customer_window=window.open('Customer.aspx?
formname=OpportunityForm.lblCustomer, 'customer_window';customer_window.focus()">
<img alt="Select Customer" src="../images/choose.gif" border="0" /></a></td>
</tr>
Code:
Dim objOpportunity As Opportunity
sub Page_Load
If Not Page.IsPostBack Then
LoadOpportunity("031276ADM")
End If
end sub
Private Sub LoadOpportunity(p_FileNumber)
dim objConn, objrs, SQLString
objOpportunity = New Opportunity()
SQLString = "SELECT * FROM Opportunity WHERE FileNumber = '" & p_FileNumber & "'"
objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = Application("ConnectionString")
objConn.Open
objrs = Server.CreateObject("ADODB.RecordSet")
objrs.Open (SQLString, objConn)
lblCustomer.value = GetCustomerName(objrs.Fields("Customer").Value)
objOpportunity.Customer = objrs.Fields("Customer").Value
objrs.Close
objrs = nothing
objConn.Close()
End Sub
This works so far in that it loads up the customer ID into the objOpportunity.Customer property, but I need to be able to change the objOpportunity.Customer value to the new Customer ID from the pop-up window, then come up with a way to call a Save function within the objOpportunity class itself.
Is this possible to do, or would I be better off simply using hidden inputs to store the Customer ID, then saving the values of all the hidden inputs to update my database?
Last edited: