我有3个按钮,一个取消,一个应用更改,一个保存/退出。取消和保存/退出工作正常,但应用和重新加载页面失败。单击应用/重新加载时,它会根据我尝试的方式加载未更改的版本或模板,而不是显示更新的页面。我知道这应该是一个相当简单的事情,并且当我尝试这个时在其他语言中没有问题,我已经在代码中留下了一些选项作为注释掉的部分。我继续并包括整个班级,但问题区域在btnApply_Click
Public Class create_worksheet
Inherits System.Web.UI.Page
Public Property editID As Integer
Public Property TemplateID As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
editID = Request.QueryString("id")
TemplateID = Request.QueryString("template")
If Not Page.IsPostBack Then
If (Not editID = Nothing And Not editID = 0) Then
Dim d As New Data.LINQ.LINQWorkflowDAO
Dim wf = d.GetDefaultWorkflow(editID)
If wf.ID > 0 Then
litHeading.Text = "Edit Workflow"
lblWorkflowBreadCrumb.Text = wf.Name
txtWorksheetName.Value = wf.Name
txtProcessDoc.Value = wf.DetailedProcessDocumentLink
rptPrepTasks.DataSource = wf.Tasks.Where(Function(p) p.Type = "Prep-work")
rptPrepTasks.DataBind()
rptMigrationTasks.DataSource = wf.Tasks.Where(Function(p) p.Type = "Migration")
rptMigrationTasks.DataBind()
rptPostTasks.DataSource = wf.Tasks.Where(Function(p) p.Type = "Post-migration")
rptPostTasks.DataBind()
divProcessDoc.Visible = False
Else
If Not TemplateID = Nothing Then
lblWorkflowBreadCrumb.Text = "Create Workflow"
editID = Nothing
End If
End If
ElseIf Not TemplateID = Nothing Then
Dim d2 As New Data.LINQ.LINQWorkflowDAO
Dim wf2 = d2.GetDefaultWorkflow(TemplateID)
If wf2.ID > 0 Then
litHeading.Text = "Edit Workflow"
txtProcessDoc.Value = wf2.DetailedProcessDocumentLink
rptPrepTasks.DataSource = wf2.Tasks.Where(Function(p) p.Type = "Prep-work")
rptPrepTasks.DataBind()
rptMigrationTasks.DataSource = wf2.Tasks.Where(Function(p) p.Type = "Migration")
rptMigrationTasks.DataBind()
rptPostTasks.DataSource = wf2.Tasks.Where(Function(p) p.Type = "Post-migration")
rptPostTasks.DataBind()
divProcessDoc.Visible = False
End If
If Not TemplateID = Nothing Then
lblWorkflowBreadCrumb.Text = "Create Workflow"
editID = Nothing
End If
End If
If Not IsNothing(Request.QueryString("Action")) Then lblStatus.Text = "Workflow Saved"
End If
End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
If txtWorksheetName.Value.Length > 0 Then
Dim tasks As New List(Of Data.WorkflowTask)
Dim prepTitles = Request.Form.GetValues("txtPrepTitle")
Dim migrationTitles = Request.Form.GetValues("txtMigrationTitle")
Dim postTitles = Request.Form.GetValues("txtPostTitle")
If Not IsNothing(prepTitles) Then
'prep
For i As Integer = 0 To prepTitles.Length - 1
tasks.Add(New Data.WorkflowTask With {.Name = prepTitles(i), .Type = "Prep-work"})
Next
End If
If Not IsNothing(migrationTitles) Then
'migration
For i As Integer = 0 To migrationTitles.Length - 1
tasks.Add(New Data.WorkflowTask With {.Name = migrationTitles(i), .Type = "Migration"})
Next
End If
'post
If Not IsNothing(postTitles) Then
For i As Integer = 0 To postTitles.Length - 1
tasks.Add(New Data.WorkflowTask With {.Name = postTitles(i), .Type = "Post-migration"})
Next
End If
Dim d As New Data.LINQ.LINQWorkflowDAO
Dim newid As Integer = 0
'if this is a new process, create new, else, update existing
If editID = Nothing Then
d.CreateDefaultWorkflow(txtWorksheetName.Value, tasks, txtProcessDoc.Value)
Else
newid = d.UpdateDefaultWorkflow(editID, txtWorksheetName.Value, tasks)
End If
lblStatus.Text = "Workflow Saved"
Dim wf = d.GetDefaultWorkflow(txtWorksheetName.Value)
'Response.Redirect("create-worksheet.aspx?id=" & wf.ID.ToString() & "&action=Saved")
Response.Redirect("default-worksheets.aspx")
Else
lblStatus.Text = "Please Enter a Name for the Workflow"
End If
End Sub
Private Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click
If txtWorksheetName.Value.Length > 0 Then
Dim tasks As New List(Of Data.WorkflowTask)
Dim prepTitles = Request.Form.GetValues("txtPrepTitle")
Dim migrationTitles = Request.Form.GetValues("txtMigrationTitle")
Dim postTitles = Request.Form.GetValues("txtPostTitle")
If Not IsNothing(prepTitles) Then
'prep
For i As Integer = 0 To prepTitles.Length - 1
tasks.Add(New Data.WorkflowTask With {.Name = prepTitles(i), .Type = "Prep-work"})
Next
End If
If Not IsNothing(migrationTitles) Then
'migration
For i As Integer = 0 To migrationTitles.Length - 1
tasks.Add(New Data.WorkflowTask With {.Name = migrationTitles(i), .Type = "Migration"})
Next
End If
'post
If Not IsNothing(postTitles) Then
For i As Integer = 0 To postTitles.Length - 1
tasks.Add(New Data.WorkflowTask With {.Name = postTitles(i), .Type = "Post-migration"})
Next
End If
Dim d As New Data.LINQ.LINQWorkflowDAO
Dim newid As Integer = 0
'if this is a new process, create new, else, update existing
If editID = Nothing Then
d.CreateDefaultWorkflow(txtWorksheetName.Value, tasks, txtProcessDoc.Value)
Else
newid = d.UpdateDefaultWorkflow(editID, txtWorksheetName.Value, tasks)
End If
lblStatus.Text = "Workflow Saved"
Dim wf = d.GetDefaultWorkflow(txtWorksheetName.Value)
'testing/issue items below
Dim originThing = d.GetDefaultWorkflow(txtWorksheetName.Value)
'Server.Transfer(Request.Path)
'Response.Redirect("default-worksheets.aspx")
' Response.Redirect("create-worksheet.aspx?id=" & originThing.ID.ToString() & "&action=Saved")
'Response.Redirect("create-worksheet.aspx?id=" & wf.ID.ToString() & "&action=Saved")
'Response.Redirect(Request.RawUrl)
'Response.Redirect(Request.RawUrl, True)
'Server.TransferRequest(Request.Url.AbsolutePath, False)
'Server.TransferRequest(Request.Url.AbsolutePath, True)
Else
lblStatus.Text = "Please Enter a Name for the Workflow"
End If
End Sub
End Class
提前感谢大家提出的任何方向,非常感谢
解决了! Response.Redirect(" create-worksheet.aspx?id ="& newid) 问题是代码分配了一个新的id,我一直回到旧的......