Reputation: 706
I am new with asp.net and vb.net.
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.net and vb.net
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.net code for btnUPDATE is as follow
Protected Sub btnUpdate_ServerClick(sender As Object, e As EventArgs) Handles btnUpdate.ServerClick
If comNewStatus.Items.Count <= 0 Then
Response.Redirect("details.aspx?i=" & Request("i"))
End If
Dim previusStatus = VacancyApplication.Status, _
newStatus = CInt(comNewStatus.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(comNewStatus.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.
Upvotes: 1
Views: 8718
Reputation: 32212
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.
Upvotes: 3