|
-
Dec 31st, 2009, 09:04 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Dynamic Confirmation Button
Is there a way to dynamically have a confirmation button pop up? I have users that assign tasks to a person for a given date. I check before inserting if that person already has something assigned that day. I would like to prompt them to continue or cancel if they are about to double book that person. I can get the prompt using RegisterStartupScript in the button click event but can’t interact with the response. Does anyone have any ideas how this might be accomplished?
-
Dec 31st, 2009, 10:54 AM
#2
Re: Dynamic Confirmation Button
Hey,
The method I have used in the past is to use a javascript confirm:
http://www.tizag.com/javascriptT/javascriptconfirm.php
Put this on the ClientClick event of your button. If you return false, the submission to the server will never happen.
Does that help?
Gary
-
Dec 31st, 2009, 12:54 PM
#3
Thread Starter
Hyperactive Member
Re: Dynamic Confirmation Button
Thanks, the thing is I won't always want to prompt. Its dynamic in the sense that I only prompt when conditions are met. I am already using the method from the link in your post by using RegisterStartupScript with that code when conditions are met. Right now the prompt is dynamic depending on conditions but I can't figure out a way to pull the response. I hope that makes sense.
-
Jan 2nd, 2010, 04:52 AM
#4
Re: Dynamic Confirmation Button
Few ways to do this.
1) Have a hidden DIV on your page, with two buttons on it (Confirm, Cancel). When you do the insert check and realize that a person is about to be double booked, make the DIV visible, in a prominent position of course. The DIV can read "Are you sure blah blah blah?" User then clicks confirm, you handle that event and finally call the actual insert code.
2) Send JS to the page such that when the OK button is clicked, you trigger a postback; handle the code for this in the codebehind and do the insert.
3) When the page is rendered the first time, store the users who are booked for "the given date" somewhere on the page, such as in a javascript variable. When the button is clicked, call this javascript function and have it check the chosen values against the "pre booked users" values.
-
Jan 4th, 2010, 11:13 AM
#5
Thread Starter
Hyperactive Member
Re: Dynamic Confirmation Button
Have a hidden DIV on your page, with two buttons on it (Confirm, Cancel). When you do the insert check and realize that a person is about to be double booked, make the DIV visible, in a prominent position of course. The DIV can read "Are you sure blah blah blah?" User then clicks confirm, you handle that event and finally call the actual insert code.
Thanks I went with this option, used a panel (div built in) instead of div but same concept.
I'm using a formview with BLL so I'll post my solution
Concept is to check during the ItemInsertingEvent if we need to prompt the user for additional action, if so make the prompt and cancel the insert otherwise let the inset go.
Here is what the panels (one for insert and one for confirm) look like in the formview:
Code:
<asp:Panel ID="AssigneeInsert" runat="server" visible="true">
<asp:LinkButton ID="InsertProcedureAssigneesButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert" onclick="InsertProcedureAssigneesButton_Click" />
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
<br />
</asp:Panel >
<asp:Panel ID="AssigneeConfirm" runat="server" visible="false">
<span class="style2">This will cause this person to be double booked. Continue?</span><br />
<asp:LinkButton ID="InsertProcedureAssigneesButtonConfirm" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Confirm" />
<asp:LinkButton ID="InsertCancelButton0" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</asp:Panel >
The code behind goes as follows:
Code:
Private Sub frmProcedureAssigneeChoice_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles frmProcedureAssigneeChoice.ItemInserting
Dim CheckAssignee As New AssigneeBLL
Dim AssigneeId As DropDownList = CType(frmProcedureAssigneeChoice.FindControl("ddAssigneeChoice"), DropDownList)
'Call to see if we are about to double book.
If CheckAssignee.PreviouslyScheduled(txtFileID.Text, txtProcedureTestID.Text, AssigneeId.SelectedValue) = True Then
Dim ConfirmPanel As Panel = frmProcedureAssigneeChoice.FindControl("AssigneeProcedureConfirm")
'If already visible let the insert go through since they are hitting confirm
If ConfirmPanel.Visible = True Then
Exit Sub
End If
'Give the option to hit the confirm button
ConfirmPanel.Visible = True
'Hide the insert button
Dim InsertPanel As Panel = frmProcedureAssigneeChoice.FindControl("AssigneeProcedureInsert")
InsertPanel.Visible = False
e.Cancel = True
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|