 |
| ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 13th, 2010, 01:01 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Can't get linkbutton to work
I want to use linkbuutons so that I can avoid using querystrings I can't get them to work. The CommandArgument is, for example, Purchaser1PersonKey which is an integer In my subs I can't e.CommandArgument.ToString to be the value of Purchaser1Person Key
Protected Sub lnkPurchaser1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Session("personid") = e.CommandArgument.ToString
Response.Redirect("PeopleDetail.aspx")
End Sub
Protected Sub lnkPurchaser2_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Session("personid") = e.CommandArgument.ToString
Response.Redirect("PeopleDetail.aspx")
End Sub Full Code shown below CODE] <%@PageTitle="Deal Summary"Language="VB"MasterPageFile="~/secureds_deals.master" %>
<%@RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>
<scriptrunat="server">
Protected OfferStatus AsString
Protected offerid AsInteger
Protected OfferType AsString
Protected OfferDateTime As DateTime
Protected PctDown As Int16
Protected OfferAmount As Int32
Protected SuggestedClosingDate AsDate
Protected CompletePct As Int16
Protected Guarantor AsString
Protected Contingencies AsString
Protected Notes AsString
Protected MostRecent AsBoolean
Protected StreetAddress1, StreetAddress2, City, State, Country, PostalCode AsString
Protected Purchaser1FName, Purchaser1LName AsString
Protected Purchaser2FName, Purchaser2LName AsString
Protected BuyersAgentFName, BuyersAgentLName AsString
Protected viewed AsBoolean
Protected lastvieweddate AsDate
Protected EmploymentStatus AsString
Protected IncomeThisYear AsString
Protected IncomeLastYear AsString
Protected IncomePrevYear AsString
Protected Salary AsString
Protected YearsAtCurrentPosition AsString
Protected NWUploaded AsBoolean
Protected FinUploaded AsBoolean
Protected MtgPreApproveUploaded AsBoolean
Protected SecondHome AsString
Protected Pets AsString
Protected SpecialConditions AsString
Protected PropertyType AsString
Protected Purchaser1PersonKey AsInteger
Protected Purchaser2PersonKey AsInteger
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs)
'txtLName.Text = "Greenbaum"
IfNot IsPostBack Then
'This is initial page load
'Session("DealID") should have been passed in
lblDealId.Text = "Deal ID: " & Session("DealId")
lblDealName.Text = "Deal Name: " & Session("DealName")
lblOfferNumber.Text = "Offer No: " & Session("Offernumber")
If Session("DealID") <= 0 Then Server.Transfer("Deals.aspx")
InitializeDateSelectDdls()
If Session("offernumber") > 0 Then GetOfferData(Session("offernumber"))
PopulateAccordion()
Else
'Postback()
'Postback may have occurred because selected month changed
'If so, ddlDay needs to be updated to have the correct number of days in its list
InitializeDayDdl()
If chkPropertyViewed.Checked = "true"Then
pnlViewDates.Visible = "true"
Else
pnlViewDates.Visible = "false"
EndIf
EndIf
EndSub
ProtectedSub InitializeDateSelectDdls()
' Initialise month
For month AsInteger = 1 To 12
Me.ddlMonth.Items.Add(New ListItem(month.ToString(), month.ToString()))
Next
InitializeDayDdl()
EndSub
ProtectedSub InitializeDayDdl()
ddlDay.Items.Clear()
For day AsInteger = 1 To DateTime.DaysInMonth(DateTime.Now.Year, Convert.ToInt32(ddlMonth.SelectedItem.Value))
ddlDay.Items.Add(New ListItem(day.ToString(), day.ToString()))
Next
EndSub
ProtectedSub GetOfferData(ByVal offernumber AsInteger)
Dim Conn AsNew SqlConnection(dsDeals.ConnectionString)
Dim dataSet AsNew DataSet()
Dim adapter As SqlDataAdapter
Dim CmdGetOfferData AsNew SqlCommand("procGetOfferByDealIDandOfferNumberSelect", Conn)
Dim dealidparam AsNew SqlParameter("@dealid", SqlDbType.Int)
Dim offernumberparam AsNew SqlParameter("@offernumber", SqlDbType.Int)
CmdGetOfferData.CommandType = Data.CommandType.StoredProcedure
dealidparam.Value = Session("DealId")
offernumberparam.Value = offernumber
CmdGetOfferData.Parameters.Add(dealidparam)
dealidparam.Direction = Data.ParameterDirection.Input
CmdGetOfferData.Parameters.Add(offernumberparam)
offernumberparam.Direction = Data.ParameterDirection.Input
Conn.Open()
adapter = New SqlDataAdapter(CmdGetOfferData)
Try
adapter.Fill(dataSet)
OfferStatus = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(0), String)
offerid = CInt(dataSet.Tables(0).Rows(0).ItemArray(1))
OfferType = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(2), String)
OfferDateTime = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(3), Date)
PctDown = CInt(dataSet.Tables(0).Rows(0).ItemArray(4))
OfferAmount = CInt(dataSet.Tables(0).Rows(0).ItemArray(5))
SuggestedClosingDate = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(6), String)
CompletePct = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(7), Int16)
Guarantor = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(8), String)
Contingencies = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(9), String)
Notes = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(10), String)
MostRecent = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(11), Boolean)
StreetAddress1 = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(12), String)
StreetAddress2 = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(13), String)
City = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(14), String)
State = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(15), String)
Country = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(16), String)
PostalCode = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(17), String)
Purchaser1FName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(18), String)
Purchaser1LName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(19), String)
Purchaser2FName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(20), String)
Purchaser2LName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(21), String)
BuyersAgentFName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(22), String)
BuyersAgentLName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(23), String)
viewed = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(24), Boolean)
lastvieweddate = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(25), Date)
EmploymentStatus = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(26), String)
IncomeThisYear = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(27), String)
IncomeLastYear = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(28), String)
IncomePrevYear = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(29), String)
Salary = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(30), String)
YearsAtCurrentPosition = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(31), String)
NWUploaded = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(32), Boolean)
FinUploaded = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(33), Boolean)
MtgPreApproveUploaded = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(34), Boolean)
SecondHome = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(35), String)
Pets = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(36), String)
SpecialConditions = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(37), String)
PropertyType = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(38), String)
Purchaser1PersonKey = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(39), Integer)
Purchaser2PersonKey = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(40), Integer)
Catch
Conn.Close()
lblMessage2.Text = "Offer Number: " & offernumber & " Something went wrong. Could not locate offer data"
EndTry
EndSub
ProtectedSub PopulateAccordion()
PopulateProperty()
PopulatePurchaser()
EndSub
ProtectedSub PopulateProperty()
Dim sb AsNew StringBuilder(StreetAddress1 & "<br/>")
sb.Append(StreetAddress2 & "<br/>")
sb.Append(City & ", " & State & " " & PostalCode & "<br/>")
sb.Append(Country)
lblProperty.Text = sb.ToString
If viewed = TrueThen
chkPropertyViewed.Checked = "true"
Else
chkPropertyViewed.Checked = "false"
ddlDay.Enabled = "False"
ddlMonth.Enabled = "False"
ddlYear.Enabled = "False"
EndIf
EndSub
ProtectedSub PopulatePurchaser()
If Purchaser2FName = "None"Then
lnkPurchaser2.Visible = "False"
lblPurchaser2.Visible = "True"
Else
lnkPurchaser2.Visible = True
lblPurchaser2.Visible = False
EndIf
lblGuarantor.Text = Guarantor
EndSub
ProtectedSub btnSubmit_Click(ByVal sender AsObject, ByVal e As System.EventArgs)
EndSub
ProtectedSub lnkPurchaser1_Command(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Session("personid") = e.CommandArgument.ToString
Response.Redirect("PeopleDetail.aspx")
EndSub
ProtectedSub lnkPurchaser2_Command(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Session("personid") = e.CommandArgument.ToString
Response.Redirect("PeopleDetail.aspx")
EndSub
</script>
<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">
<asp:ScriptManagerID="ScriptManager1"runat="server">
</asp:ScriptManager>
<asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<divclass="accordion">
<asp:LabelID="lblDealId"runat="server"class="label"Text=""></asp:Label><br/>
<asp:LabelID="lblDealName"runat="server"class="label"Text=""></asp:Label><br/>
<asp:LabelID="lblOfferNumber"runat="server"class="label"Text=""></asp:Label><br/>
<asp:LabelID="lblMessage2"runat="server"class="label"Text=""></asp:Label><br/>
<cc1:AccordionID="Accordion1"runat="server"SelectedIndex="0"
HeaderCssClass="accordionHeader"ContentCssClass="accordionContent"FadeTransitions="true"FramesPerSecond="40"TransitionDuration="250"AutoSize="None">
<Panes>
<cc1:AccordionPaneID="AccordionPane1"runat="server">
<Header>
<ahref=""onclick="return false;"class="accordionLink">Property</a>
</Header>
<Content>
<asp:LabelID="lblProperty"runat="server"Text=""class="label"></asp:Label>
<br/>
<asp:CheckBoxID="chkPropertyViewed"class="checkbox"runat="server"AutoPostBack="true"Checked="true"Text="Property Has Been Viewed"/>
<asp:PanelID="pnlViewDates"runat="server">
<p>When was property last viewed?</p><p>
Mon
<asp:DropDownListID="ddlMonth"runat="server"AutoPostBack="true">
</asp:DropDownList>
Day<asp:DropDownListID="ddlDay"runat="server">
</asp:DropDownList>
Year<asp:DropDownListID="ddlYear"runat="server">
<asp:ListItem>2010</asp:ListItem>
<asp:ListItem>2011</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
</asp:DropDownList>
</p>
</asp:Panel>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPaneID="AccordionPane2"runat="server">
<Header>
<ahref=""onclick="return false;"class="accordionLink">Purchaser</a>
</Header>
<Content>
<p>
<asp:LabelID="Label12"runat="server"Text="Purchaser: "></asp:Label>
<asp:LinkButtonID="lnkPurchaser1"class="linkbutton"runat="server"CommandName="GoToPurchaser1"CommandArgument='<%#Eval( "Purchaser1PersonKey") %>'OnCommand="lnkPurchaser1_Command"><%=Purchaser1FName & " " & Purchaser1LName%></asp:LinkButton>
</p>
<p>
<asp:LabelID="Label15"runat="server"Text="Co-Purchaser: "></asp:Label>
<asp:LinkButtonID="lnkPurchaser2"runat="server"CommandArgument="Purchaser2PersonKey"OnCommand="lnkPurchaser2_Command"CommandName="GoToPurchaser2"><%=Purchaser2FName & " " & Purchaser2LName%></asp:LinkButton>
<asp:LabelID="lblPurchaser2"runat="server"Text="None"></asp:Label>
</p>
<p>
<asp:LabelID="Label21"runat="server"Text="Guarantor: "></asp:Label>
<asp:LabelID="lblGuarantor"runat="server"></asp:Label>
</p>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPaneID="AccordionPane3"runat="server">
<Header>
<ahref=""onclick="return false;"class="accordionLink">Offer</a>
</Header>
<Content>
<p>
<asp:LabelID="Label1"class="formlabel"runat="server"Text="Offer Amount">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="txtOfferAmount"
runat="server">
</asp:TextBox>
</p>
<p>
<asp:LabelID="Label2"class="formlabel"runat="server"Text="% Down">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="TextBox1"
runat="server">
</asp:TextBox>
<asp:LabelID="Label4"class="formlabel"runat="server"Text="(Required Minimum Down)">
</asp:Label>
</p><asp:LabelID="Label5"class="formlabel"runat="server"Text="Suggested Closing Date">
</asp:Label>
<p>
<asp:RadioButtonListID="RadioButtonList1"runat="server">
<asp:ListItem>ASAP</asp:ListItem>
<asp:ListItem>Flexible</asp:ListItem>
<asp:ListItem>On Specific Date</asp:ListItem>
</asp:RadioButtonList>
</p>
<p><asp:CalendarID="Calendar1"runat="server"></asp:Calendar>
</p>
<p>
* Required
</p>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPaneID="AccordionPane4"runat="server">
<Header>
<ahref=""onclick="return false;"class="accordionLink">Financial</a>
</Header>
<Content>
<p><asp:LabelID="Label8"class="formlabel"runat="server"Text="Income-Last Year">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="txtIncomeLastYear"
runat="server">
</asp:TextBox>
</p>
<p><asp:LabelID="Label28"class="formlabel"runat="server"Text="Income-Previous Year">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="txtIncomePreviousYear"
runat="server">
</asp:TextBox>
</p><p>
<asp:LabelID="Label11"class="formlabel"runat="server"Text="Employment Status">
</asp:Label><br/>
<asp:ListBoxclass="formtextbox"ID="lboEmploymentHistory"
runat="server">
<asp:ListItem>Employed</asp:ListItem>
<asp:ListItem>Self-Employed</asp:ListItem>
<asp:ListItem>Retired</asp:ListItem>
<asp:ListItem>Unemployed</asp:ListItem>
</asp:ListBox>
</p>
<p><asp:LabelID="Label19"class="formlabel"runat="server"Text="Salary">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="txtSalary"
runat="server">
</asp:TextBox>
</p>
<p><asp:LabelID="Label24"class="formlabel"runat="server"Text="Bonus">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="txtBonus"
runat="server">
</asp:TextBox>
</p>
<p><asp:LabelID="Label26"class="formlabel"runat="server"Text="Years At Current Position">
</asp:Label>
<asp:TextBoxclass="formtextbox"ID="txtYearsAtCurrentPosition"
runat="server">
</asp:TextBox>
<p><asp:LabelID="Label14"runat="server"Text="Net Worth Statement"></asp:Label>
<asp:FileUploadID="FileUpload3"runat="server"/></p>
<p><asp:LabelID="Label18"runat="server"Text="Financial Form"></asp:Label>
<asp:FileUploadID="FileUpload4"runat="server"/></p>
<p><asp:LabelID="Label7"runat="server"Text="Mortgage Pre-Approval"></asp:Label>
<asp:FileUploadID="FileUpload2"runat="server"/></p>
<asp:ButtonID="btnUpload"runat="server"Text="Upload"/>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPaneID="AccordionPane5"runat="server">
<Header>
<ahref=""onclick="return false;"class="accordionLink">Other</a>
</Header>
<Content>
<p>Second Home</p>
<p>Special Conditions</p>
<p>Pets</p>
</Content>
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<divstyle="position:relative;clear:left;float:left;">
<asp:ButtonID="btnSubmit"runat="server"Text="Save"onclick="btnSubmit_Click"/>
<asp:LabelID="lblMessage"runat="server"Text=""></asp:Label>
</div>
<asp:SqlDataSourceID="dsDeals"runat="server"ConnectionString="<%$ ConnectionStrings:DB_6056_securedeConnectionString %>">
</asp:SqlDataSource>
</asp:Content>
[/CODE]
|
|
 |