在asp.net VB打开新窗口 [英] Open new window in asp.net VB
问题描述
我正在工作的东西我们公司的小白progammer。我工作的一个测验引擎进行训练。我有一些样本code是90%左右建成。我只需要调整一些东西。这里就是我的工作。
I'm a noob progammer that is working on something for our company. I'm working on a Quiz engine for training. I have some sample code that is about 90% built. I just need to tweak a few things. Here's what I'm working on.
这是建立在ASP.net用VB。我有一组IM,从数据库中提取的问题(使用内置的SqlDataSource绑定)。目前,它的作用是拉动问题,你选择答案,然后单击下一步。然后拉了下一个问题列表等等....直到结束。该数据库包含一列,表明正确的答案是什么。当你点击下一步,它compairs你的答案正确答案,并将其存储,然后继续下一个问题。在最后,它吐出你的正确答案和不正确的答案。
THis is built in ASP.net with VB. I have a set of questions that I"m pulling from a database (using the built-in SQLDataSource binding). Currently what it does is pull the question, you select the answer, and click Next. It then pulls the next question in the list and so forth....till the end. The Database contains a column that indicates what the correct answer is. When you click next, it compairs your answer to the correct answer, stores it, then continues to the next question. At the end, it spits out your correct answers and incorrect answers.
然而,这就是我想做的事情。当用户选择一个答案,接下来的点击,它会立即开辟了一个新的小窗口(未弹出,但在同一页上的一个窗口)在紧随等级这个问题,并在该窗口中显示它是否是正确的。 .something是这样的:
However, this is what I want to do. When the user selects an answer and clicks next, it immediately opens up a small new window (not a pop-up, but a window on the same page) that immediately "grades" that question and in that window, displays whether it's correct..something like this:
If selected answer = correctAnswer then
"That is correct"
Else
"THat is not correct. The correct answer is B"
End if
新的窗口将只包含在底角的确定按钮。当确定为pressed,它关闭了新窗口和处理什么样的下一步按钮编程做休息。下面是按钮:
The new window will only contain an "OK" button in the bottom corner. When the OK is pressed, it closes that new window and processes the rest of what the "next" button is programmed to do. Here is the button:
<asp:Button ID="buttonNext" runat="server" Text="Next" /> </td>
下面是Questions.aspx.VB code到与附和:
Here is the Questions.aspx.VB code to go along with that:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonNext.Click
' Save off previous answers
Dim dr As System.Data.DataRowView
dr = CType(questionDetails.DataItem, System.Data.DataRowView)
' Create Answer object to save values
Dim a As Answer = New Answer()
a.QuestionID = dr("QuestionOrder").ToString()
a.CorrectAnswer = dr("CorrectAnswer").ToString()
a.UserAnswer = answerDropDownList.SelectedValue.ToString()
Dim al As ArrayList
al = CType(Session("AnswerList"), ArrayList)
al.Add(a)
Session.Add("AnswerList", al)
If questionDetails.PageIndex = questionDetails.PageCount - 1 Then
' Go to evaluate answers
Response.Redirect("results.aspx")
Else
questionDetails.PageIndex += 1
End If
If questionDetails.PageIndex = questionDetails.PageCount - 1 Then
buttonNext.Text = "Finished"
End If
End Sub
如果你能够提供code我需要的,这将是有益的。在此先感谢您的帮助。
If you are able to provide the code I need, that will be helpful. Thanks in advance for the help.
添
推荐答案
这应该是相当直截了当。正如你已经获取了正确的答案是没有必要做另一个电话。
This should be fairly straight forward. As you have already retrieved the correct answer there is no need to do another call.
在你的页面中,您需要创建一个你想要的分级和OK键住。
像这样的东西就足够了:
On your page you need to create a where you want the grading and OK button to live. Something like this would suffice:
<div id="gradeWindow" runat="server" visible="false">
<asp:label id="gradeLabel" runat="server" text="" />
<asp:button id="gradeOK" runat="server" text="OK" onclick="gradeOK_Clicked" />
</div>
然后修改你的函数看起来像这样
Then modify your function to look like this
Session.Add("AnswerList", al)
If String.Compare(a.UserAnswer, a.CorrectAnswer) = 0 then
gradeLabel.Text = "That is correct"
Else
gradeLabel.Text = "That is not correct. The correct answer is " + a.CorrectAnswer
EndIf
gradeWindow.Visible = true
End Sub
Protected Sub gradeOK_Clicked(ByVal sender As Object, ByVal e As System.EventArgs)
If questionDetails.PageIndex = questionDetails.PageCount - 1
Then
Response.Redirect("results.aspx")
Else
questionDetails.PageIndex += 1
End If
If questionDetails.PageIndex = questionDetails.PageCount - 1
Then
buttonNext.Text = "Finished"
End If
End Sub
这篇关于在asp.net VB打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!