javascript - How to close a popup form after saving in asp.net and vb.net web application - Stack Overflow

I am new with asp and vb. I am maintaining a web application which contains many users and their inform

I am new with asp and vb.

I am maintaining a web application which contains many users and their information. From the list.aspx page if some one clicks any individual name from the list it goes to another page called update_status.aspx which contains the information of a particular user. This page produces a form where we can update the information about that user by clicking update button in that form. After clicking the update button it saves the update and redicets to details.aspx page.

Now this update_status.aspx page is converted into a popup page and renamed as update_status_popup.aspx

Now the requirement is to close the popup window after update when someone clicks update and dont redirect to details.aspx page

How can I do that. The webpage is built with asp and vb

I am including the codes below.

The following link opens the popup window called Update_status_popup.aspx

 <a class="hover-glow" style="cursor:pointer;"  data-placement="bottom" rel="tooltip" title="change status" data-bind="click: $parent.openPopup"><i class="icon icon-random"></i>                                     </a>

In the update_staus_popup.aspx the code for the update button is

<div class="btn-wrapper">
            <button runat="server" id="btnUpdate" class="btn" data-bind="enable: ((statusId() == 10 && offeredSalary() < 0) || (statusId() == 11 && finalSalary() < 0) || (feeType() == 2 && introductionFee() <= 0 && statusId() == 11 && agencyApp() == 'True')) ? false : true">Update</button>
            <a class="btn" href="javascript:window.close();">Close</a>
        </div>

there are two button UPDATE and CLOSE. Close button also closes the window but the client requires to close the form automatically after updating.

the present VB code for btnUPDATE is as follow

 Protected Sub btnUpdate_ServerClick(sender As Object, e As EventArgs) Handles btnUpdate.ServerClick



    If NewStatus.Items.Count <= 0 Then
        Response.Redirect("details.aspx?i=" & Request("i"))
    End If


    Dim previusStatus = VacancyApplication.Status, _
        newStatus = CInt(NewStatus.Value)


    If newStatus <> VacancyApplication.StatusID Then


        Try

            If newStatus = 10 Then
                VacancyApplication.OfferedSalary = CType(txtOfferedSalary.Value, Decimal)
                VacancyApplication.AddNote("Offered: " & txtOfferedSalary.Value)
            ElseIf newStatus = 11 Then

                VacancyApplication.AddNote("Final salary: " & txtFinalSalary.Value)
                Vacancy.FinalSalary = CDec(txtFinalSalary.Value)
                Vacancy.Save()
                If Vacancy.FeeType = 1 AndAlso CDec(txtFinalSalary.Value) > 0 Then
                    Vacancy.CalculateFees()
                    Vacancy.SaveFees()
                End If
                Dim vh As New VacancyHistory With {.VacancyID = VacancyApplication.VacancyID, .Description = "Final salary added. Amount:" & txtFinalSalary.Value}
                vh.Save()
            ElseIf newStatus = 12 Then
                VacancyApplication.StartDate = CDate(txtStartDate.Value)
                VacancyApplication.AddNote("Start date: " & txtStartDate.Value)
            End If


            If Vacancy.FeeType = 2 AndAlso CDec(txtFinalIntroductionFee.Value) Then
                Vacancy.SetFinalIntroductionFee(CDec(txtFinalIntroductionFee.Value))
                Dim vh As New VacancyHistory With {.VacancyID = VacancyApplication.VacancyID, .Description = "Introduction fee added as per variable fee type. Fee:" & txtFinalIntroductionFee.Value}
                vh.Save()
            End If
            VacancyApplication.Save()
            VacancyApplication.UpdateStatus(CInt(NewStatus.Value), True, False)

        Catch ex As Exception
            _logger.Fatal(ex.Message)
            Response.Redirect("/E4/Error/500.aspx")
        End Try

        If Not String.IsNullOrWhiteSpace(txtNote.Value) Then VacancyApplication.AddNote(txtNote.Value.Trim())

        _logger.Fatal("details.aspx?i=" & VacancyApplication.ID & "&c=" & VacancyApplication.StatusID)


    End If
    Response.Redirect("details.aspx?i=" & VacancyApplication.ID & "&c=" & VacancyApplication.StatusID)

End Sub
End Class

The above code redirects the page to details.aspx page (which also opens in the same popupup and does not look smart.). Please suggest me with the code which will close the update_status_popup.aspx page after saving the details.

I am new with asp and vb.

I am maintaining a web application which contains many users and their information. From the list.aspx page if some one clicks any individual name from the list it goes to another page called update_status.aspx which contains the information of a particular user. This page produces a form where we can update the information about that user by clicking update button in that form. After clicking the update button it saves the update and redicets to details.aspx page.

Now this update_status.aspx page is converted into a popup page and renamed as update_status_popup.aspx

Now the requirement is to close the popup window after update when someone clicks update and dont redirect to details.aspx page

How can I do that. The webpage is built with asp and vb

I am including the codes below.

The following link opens the popup window called Update_status_popup.aspx

 <a class="hover-glow" style="cursor:pointer;"  data-placement="bottom" rel="tooltip" title="change status" data-bind="click: $parent.openPopup"><i class="icon icon-random"></i>                                     </a>

In the update_staus_popup.aspx the code for the update button is

<div class="btn-wrapper">
            <button runat="server" id="btnUpdate" class="btn" data-bind="enable: ((statusId() == 10 && offeredSalary() < 0) || (statusId() == 11 && finalSalary() < 0) || (feeType() == 2 && introductionFee() <= 0 && statusId() == 11 && agencyApp() == 'True')) ? false : true">Update</button>
            <a class="btn" href="javascript:window.close();">Close</a>
        </div>

there are two button UPDATE and CLOSE. Close button also closes the window but the client requires to close the form automatically after updating.

the present VB code for btnUPDATE is as follow

 Protected Sub btnUpdate_ServerClick(sender As Object, e As EventArgs) Handles btnUpdate.ServerClick



    If NewStatus.Items.Count <= 0 Then
        Response.Redirect("details.aspx?i=" & Request("i"))
    End If


    Dim previusStatus = VacancyApplication.Status, _
        newStatus = CInt(NewStatus.Value)


    If newStatus <> VacancyApplication.StatusID Then


        Try

            If newStatus = 10 Then
                VacancyApplication.OfferedSalary = CType(txtOfferedSalary.Value, Decimal)
                VacancyApplication.AddNote("Offered: " & txtOfferedSalary.Value)
            ElseIf newStatus = 11 Then

                VacancyApplication.AddNote("Final salary: " & txtFinalSalary.Value)
                Vacancy.FinalSalary = CDec(txtFinalSalary.Value)
                Vacancy.Save()
                If Vacancy.FeeType = 1 AndAlso CDec(txtFinalSalary.Value) > 0 Then
                    Vacancy.CalculateFees()
                    Vacancy.SaveFees()
                End If
                Dim vh As New VacancyHistory With {.VacancyID = VacancyApplication.VacancyID, .Description = "Final salary added. Amount:" & txtFinalSalary.Value}
                vh.Save()
            ElseIf newStatus = 12 Then
                VacancyApplication.StartDate = CDate(txtStartDate.Value)
                VacancyApplication.AddNote("Start date: " & txtStartDate.Value)
            End If


            If Vacancy.FeeType = 2 AndAlso CDec(txtFinalIntroductionFee.Value) Then
                Vacancy.SetFinalIntroductionFee(CDec(txtFinalIntroductionFee.Value))
                Dim vh As New VacancyHistory With {.VacancyID = VacancyApplication.VacancyID, .Description = "Introduction fee added as per variable fee type. Fee:" & txtFinalIntroductionFee.Value}
                vh.Save()
            End If
            VacancyApplication.Save()
            VacancyApplication.UpdateStatus(CInt(NewStatus.Value), True, False)

        Catch ex As Exception
            _logger.Fatal(ex.Message)
            Response.Redirect("/E4/Error/500.aspx")
        End Try

        If Not String.IsNullOrWhiteSpace(txtNote.Value) Then VacancyApplication.AddNote(txtNote.Value.Trim())

        _logger.Fatal("details.aspx?i=" & VacancyApplication.ID & "&c=" & VacancyApplication.StatusID)


    End If
    Response.Redirect("details.aspx?i=" & VacancyApplication.ID & "&c=" & VacancyApplication.StatusID)

End Sub
End Class

The above code redirects the page to details.aspx page (which also opens in the same popupup and does not look smart.). Please suggest me with the code which will close the update_status_popup.aspx page after saving the details.

Share Improve this question asked Jun 19, 2014 at 8:19 BashabiBashabi 7062 gold badges14 silver badges45 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

You can use RegisterClientScriptBlock

Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),"CloseWindowScript","window.close();",True)

Use this in place of Response.Redirect; it will inject the call to window.close() when the page reloads, causing the window to close.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745383854a4625352.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信