Click here to Skip to main content
15,355,944 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<pre lang="text">I have a button click event.
in it , 
after satisfying some condition, I should get a confirmation dialog.
When I click "OK" button of that confirmation dialog, I want to proceed further in my code on server side.


SetUp.Aspx Code
<pre>

ASP.NET
<asp:ImageButton ID="btnCreateJob" ImageUrl="~/Images/btn_create_new_request.gif"
                            runat="server"  OnClick="btnCreateJob_Click" />


VB
Setup.Aspx.vb Code
<pre lang="ASP.NET">Protected Sub btnCreateJob_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnCreateJob.Click

        Dim UserID As String = ddlUsrId.SelectedValue.ToString()
        Dim requestType As String = ddlRequestTypes.SelectedValue.ToString()
        Dim producttype As String = ddlProduct.SelectedValue.ToString()
        Dim taxyear As String = ddlTaxyear.Items(0).Value
        Try
            If ddlRequestTypes.SelectedValue.Trim() = "RC1" AndAlso producttype = "M" AndAlso UserID = "UT" Then
                Dim Job_CreateTime As String = Common.Business.Jobsetup.GetCompletedCombinableJobsDetail(taxyear)
                If Job_CreateTime = "" Then
                    ScriptManager.RegisterStartupScript(Me.Page, Page.[GetType](), "showalert", "confirm('There is no request in the table. Please proceed with the request')", True)

                    'My doubt Is this
                    If (ok button clicked)
                        {
                          InsertNewJob(taxyear, UserID)
                        }
                        Else
                        {
                        //do Not insert
                        }
                     End If

                Else
                    ScriptManager.RegisterStartupScript(Me.Page, Page.[GetType](), "showalert", "confirm('The request is already submitted on " + Job_CreateTime + " do you want to place a new request?')", True)

                    If (ok button clicked)
                    {
                      InsertNewJob(taxyear, UserID)
                    }
                    Else
                    {
                    //do Not insert
                    }                   

                    End If
            End If
        Catch ex As Exception

        End Try
    End Sub


I am not good at ASP, Please help me on this,
Or please give if there is any better approach to implement this.

Thanks in advance.

What I have tried:

Protected Sub btnCreateJob_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnCreateJob.Click

        Dim UserID As String = ddlUsrId.SelectedValue.ToString()
        Dim requestType As String = ddlRequestTypes.SelectedValue.ToString()
        Dim producttype As String = ddlProduct.SelectedValue.ToString()
        Dim taxyear As String = ddlTaxyear.Items(0).Value
        Try
            If ddlRequestTypes.SelectedValue.Trim() = "RC1" AndAlso producttype = "M" AndAlso UserID = "UT" Then
                Dim Job_CreateTime As String = Common.Business.Jobsetup.GetCompletedCombinableJobsDetail(taxyear)
                If Job_CreateTime = "" Then
                    ScriptManager.RegisterStartupScript(Me.Page, Page.[GetType](), "showalert", "confirm('There is no request in the table. Please proceed with the request')", True)

                    'My doubt Is this
                    If (ok button clicked)
                        {
                          InsertNewJob(taxyear, UserID)
                        }
                        Else
                        {
                        //do Not insert
                        }
                     End If

                Else
                    ScriptManager.RegisterStartupScript(Me.Page, Page.[GetType](), "showalert", "confirm('The request is already submitted on " + Job_CreateTime + " do you want to place a new request?')", True)

                    If (ok button clicked)
                    {
                      InsertNewJob(taxyear, UserID)
                    }
                    Else
                    {
                    //do Not insert
                    }                   

                    End If
            End If
        Catch ex As Exception

        End Try
    End Sub
Posted
Updated 8-Apr-21 3:59am

1 solution

You can't.
The page is only displayed after it's been rendered, and that only happens once the whole page has been received by the browser.
You can display a message from the page using a Javascript Alert function[^] but your code behind can't "wait there" until the user has done something about it.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900