Modal Window
-
Thursday, July 26, 2012 3:18 PM
Hello,
I have just starting learning LightSwitch and think it's great.
I would like to extend the modal window in edit mode. I've implemented the add/edit dialog by Sheel Shah but would like to add more functionality but I need help/direction. In the below image the modal displays my selected inventory item and in this case it's a length of rope 230 feet long. I would like to cut the rope and have 3 pieces and then display dynamically a table with textboxes and 2 dropdownlists then submit the information back adding the x number of new records and updateing the orginal record changing only the status from "Pass" to "Fail".
Is this even possible? Should I look into Silverlight Controls for this? Can it be done in the pages Details screen?
I appriciate any and all help. ThanksI have created the below and in asp.net and the code is below.
Dim SID As Decimal Dim RopeLength As Integer Dim RopePieces As Integer = 1 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim OrginalSID As Decimal = 121.1 Label2.Text = "SID: " Label1.Text = OrginalSID RopeLength = 230 If Not Page.IsPostBack Then Else RopePieces = Convert.ToInt32(TextBox1.Text) Add_Control() End If End Sub Protected Sub Add_Control() Dim tbl As New Table() tbl.CellPadding = 5 tbl.CellSpacing = 1 Dim headrow As New TableRow() headrow.BackColor = Drawing.Color.LightBlue Dim headPiece As New TableCell() headPiece.Text = "Piece #" headrow.Cells.Add(headPiece) Dim headNewSID As New TableCell() headNewSID.Text = "New SID" headrow.Cells.Add(headNewSID) Dim headLength As New TableCell() headLength.Text = "Length" headrow.Cells.Add(headLength) Dim headType As New TableCell() headType.Text = "Type" headrow.Cells.Add(headType) Dim headStatus As New TableCell() headStatus.Text = "Status" headrow.Cells.Add(headStatus) tbl.Rows.Add(headrow) For i As Integer = 1 To RopePieces Dim row As New TableRow() Dim [Piece] As New TableCell() [Piece].Text = i row.Cells.Add([Piece]) Dim [NewSID] As New TableCell() NewSID.Text = Label1.Text & "." & (i).ToString row.Cells.Add(NewSID) Dim Length As New TableCell() Dim LengthTextBox As New TextBox() LengthTextBox.MaxLength = 3 LengthTextBox.Width = 30 LengthTextBox.ID = "LengthTextBox" & i Length.Controls.Add(LengthTextBox) row.Cells.Add(Length) Dim RopeType As New TableCell() Dim RopeTypeDDL = New DropDownList() RopeTypeDDL.ID = "TypeDDL" & i RopeTypeDDL.Items.Add(New ListItem("Climbing Rope", "Climbing Rope")) RopeTypeDDL.Items.Add(New ListItem("Haul Rope", "Haul Rope")) RopeType.Controls.Add(RopeTypeDDL) row.Cells.Add(RopeType) Dim Status As New TableCell() Dim RopeStatusDDL = New DropDownList() RopeStatusDDL.ID = "StatusDDL" & i RopeStatusDDL.Items.Add(New ListItem("Pass", "Pass")) RopeStatusDDL.Items.Add(New ListItem("Fail", "Fail")) RopeStatusDDL.Items.Add(New ListItem("In Use", "In Use")) RopeStatusDDL.Items.Add(New ListItem("Out for Wash", "Out for Wash")) RopeStatusDDL.Items.Add(New ListItem("Missing", "Missing")) RopeType.Controls.Add(RopeStatusDDL) row.Cells.Add(RopeType) Status.Controls.Add(RopeStatusDDL) row.Cells.Add(Status) tbl.Rows.Add(row) Next Dim subrow As New TableRow() Dim subcell0 As New TableCell() subrow.Cells.Add(subcell0) Dim subcell1 As New TableCell() subrow.Cells.Add(subcell1) Dim subcell2 As New TableCell() subrow.Cells.Add(subcell2) Dim subcell3 As New TableCell() subrow.Cells.Add(subcell3) Dim subcell4 As New TableCell() subrow.Cells.Add(subcell4) tbl.Rows.Add(subrow) Page.FindControl("PlaceHolder1").Controls.Add(tbl) End Sub Protected Sub CutBtn_Click(sender As Object, e As EventArgs) Handles CutBtn.Click 'causes postback End Sub Private Sub ShowPopUpMsg(msg As String) Dim sb As New StringBuilder() sb.Append("alert('") sb.Append(msg.Replace(vbLf, "\n").Replace(vbCr, "").Replace("'", "\'")) sb.Append("');") ScriptManager.RegisterStartupScript(Me.Page, Me.[GetType](), "showalert", sb.ToString(), True) End Sub Protected Sub SubmitBtn_Click(sender As Object, e As EventArgs) Handles SubmitBtn.Click Dim LengthCalculation As Integer = 0 Dim PieceLength As Integer = 0 Dim EmptyTextBox As Boolean = False For i As Integer = 1 To RopePieces If DirectCast(Page.FindControl("LengthTextBox" & i), TextBox).Text = "" Then EmptyTextBox = True PieceLength = 0 Else PieceLength = Convert.ToInt32(DirectCast(Page.FindControl("LengthTextBox" & i), TextBox).Text) End If LengthCalculation += PieceLength Next If LengthCalculation <> RopeLength Then ShowPopUpMsg("Total length of pieces does not calculate to original rope length") ElseIf EmptyTextBox = True Then ShowPopUpMsg("Enter a length for each piece of rope.") End If End Sub
- Edited by NeilThibeault Thursday, July 26, 2012 5:10 PM
- Edited by NeilThibeault Thursday, July 26, 2012 10:01 PM
All Replies
-
Monday, July 30, 2012 2:07 AMModerator
Hi,
For your situation, I think Grid control is just fine.
I suggest you to to add the Grid control by your own.
There is the Grid Class Document:
http://msdn.microsoft.com/en-us/library/system.windows.controls.grid%28v=VS.95%29.aspx
Grid.SetColumn(DeptStackPanel, 1); Grid.SetRow(DeptStackPanel, 1);
it the way.- Marked As Answer by Otomii LuModerator Tuesday, August 07, 2012 5:40 AM
-
Monday, July 30, 2012 11:01 AMModeratorI agree with Otomii. You don't need a custom Silverlight control for this, just a bit of behind-the-scenes coding, and a related table, to simulate the action of cutting the rope. Isn't there a game that does thta? LOL
Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands If you find a reply helpful, please click "Vote as Helpful", if a reply answers your question, please click "Mark as Answer" By doing this you'll help people find answers faster.

