Nivi sharma

Nivi sharma

  • 1.8k
  • 220
  • 5.2k

if condition is right then goes to next page in asp.net

Oct 16 2020 2:10 AM
hi experts...
 
my scenario is when user enter its right answer then it goes to next page otherwise shows an error "incorrect error"
  1. <table>  
  2. <tr>  
  3. <td>Security Question1</td>  
  4. <td>  
  5. <asp:DropDownList ID="ddlQuestion" runat="server" AppendDataBoundItems="true">  
  6. </asp:DropDownList>  
  7. <asp:TextBox ID="TxtAnswer" runat="server"></asp:TextBox>  
  8. </td>  
  9. </tr>  
  10. <tr>  
  11. <td>  
  12. <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />  
  13. </td>  
  14. </tr>  
  15. <tr>  
  16. <td>  
  17. <asp:Label ID="lblerror" runat="server"></asp:Label>  
  18. </td>  
  19. </tr>  
  20. </table>  
  1. protected void btnSubmit_Click(object sender, EventArgs e)  
  2. {  
  3. using (var context = new schoolEntities6())  
  4. {  
  5. string username = Request.QueryString["username"];  
  6. var user = (from c in context.SecurityQuestions  
  7. where c.SecQue == ddlQuestion.SelectedItem.Value  
  8. select c).FirstOrDefault();  
  9. if (user != null)  
  10. {  
  11. schoolEntities6 db = new schoolEntities6();  
  12. Session["UserName"] = username;  
  13. Response.Redirect("/ChangePassword.aspx?username=" + username);  
  14. }  
  15. else  
  16. {  
  17. lblerror.Text = "incorrect answer";  
  18. }  
  19. }  
  20. }  
I am using this way to execute but doesn't work...

Answers (1)