Code Behind Page Page /Default.aspx.cs (C#)
Used by Page /Default.aspx (C#)
1: using System;  
2: using System.Configuration;  
3: using System.Web.UI;  
4: using System.Web.UI.WebControls;  
5: using QuizNetOnline.Logic;  
6: using Microsoft.ApplicationBlocks.Data;  
7:   
8: namespace QuiznetOnline.Web.UI  
9: {  
10:     public partial class Default : Page  
11:     {  
12:         protected void Page_Load(object sender, EventArgs e)  
13:         {  
14:             if (!Page.IsPostBack)  
15:             {  
16:                 SetSessionReferrer();  
17:                 hiddenUserName.Value = ((UserWeb)Session["userWeb"]).UserName;  
18:   
19:                 if (((UserWeb)Session["userWeb"]).UserName != "guest@quiznetonline.com")  
20:                 {  
21:                     //Update Session["userWeb"]  
22:                     UpdateUserWeb();  
23:   
24:                     if (string.IsNullOrEmpty(((UserWeb)Session["userWeb"]).NickName) &&  
25:                         !string.IsNullOrEmpty(((UserWeb)Session["userWeb"]).UserName))  
26:                     {  
27:                         Response.Redirect("~/UserLogin/ProfileMaint.aspx");  
28:                     }  
29:   
30:                     if (Convert.ToInt32(ConfigurationManager.AppSettings["NumberOfFreeQuestions"]) != 0)  
31:                     {  
32:                         ConfigureFreeAccessMessages(false, lblRestrictedUser, lblFeatureAccess, pnlFeatureAccess);  
33:                     }  
34:                     else  
35:                         pnlFeatureAccess.Visible = true;  
36:                 }  
37:                 else  
38:                 {  
39:                     if (Convert.ToInt32(ConfigurationManager.AppSettings["NumberOfFreeQuestions"]) != 0)  
40:                     {  
41:                         ConfigureFreeAccessMessages(true, lblRestrictedUser, lblFeatureAccess, pnlFeatureAccess);  
42:                     }  
43:                     else  
44:                         pnlFeatureAccess.Visible = false;  
45:                 }  
46:             }  
47:   
48:         }  
49:   
50:         private void UpdateUserWeb()  
51:         {  
52:             var userWeb = (UserWeb)Session["userWeb"];  
53:             userWeb.LoadProfileDetails(((UserWeb)Session["userWeb"]).UserName, new SqlWrapper());  
54:             userWeb.QuizType = "normal";  
55:             userWeb.LoadUserTests(false);  
56:             Session["userWeb"] = userWeb;  
57:         }  
58:   
59:         private void SetSessionReferrer()  
60:         {  
61:             if (Request.UrlReferrer != null)  
62:             {  
63:                 Session["Referrer"] = Request.UrlReferrer.ToString();  
64:             }  
65:             else  
66:             {  
67:                 Session["Referrer"] = "Referrer Unknown";  
68:             }  
69:         }  
70:   
71:   
72:   
73:         public void ConfigureFreeAccessMessages(bool isGuest, HyperLink linkRestrictedUser, Label labelFeatureAccess, Panel pnlFeatureAccess)  
74:         {  
75:   
76:             string message=string.Empty;  
77:             if (isGuest)  
78:             {  
79:                 if (Convert.ToBoolean(ConfigurationManager.AppSettings["FreeForAll"]))  
80:                 {  
81:                     message = "Get FULL access just by registering";  
82:                     linkRestrictedUser.NavigateUrl = "~/UserLogin/CreateUser.aspx";  
83:                     labelFeatureAccess.Text = "<a href='/UserLogin/CreateUser.aspx'>Access</a> to hundreds of questions just by registering.";  
84:                 }  
85:                 else  
86:                 {  
87:                     message = "Get FULL access by registering and submitting at least one .Net related question";  
88:                     linkRestrictedUser.NavigateUrl = "~/UserLogin/CreateUser.aspx";  
89:                     labelFeatureAccess.Text = "<a href='/UserLogin/CreateUser.aspx'>Access</a> to hundreds of questions by registering and submitting at least one .Net related question.";  
90:                 }  
91:   
92:             }  
93:             else  
94:             {  
95:                 linkRestrictedUser.Visible = false;  
96:                 pnlFeatureAccess.Visible = false;  
97:   
98:             }  
99:   
100:             linkRestrictedUser.Text = message;  
101:   
102:         }  
103:   
104:   
105:         protected void imgClosePopup_Click(object sender, EventArgs e)  
106:         {  
107:             Response.Redirect("Default.aspx");  
108:         }  
109:   
110:   
111:         protected void cmdContinue_Click(object sender, EventArgs e)  
112:         {  
113:             Redirect(hiddenQuiz.Value);  
114:         }  
115:   
116:         protected void cmdcsharp_Click(object sender, EventArgs e)  
117:         {  
118:             Redirect("csharp");  
119:         }  
120:   
121:         protected void cmdaspnet_Click(object sender, EventArgs e)  
122:         {  
123:             Redirect("aspnet");  
124:         }  
125:   
126:         protected void cmdnetframework_Click(object sender, EventArgs e)  
127:         {  
128:             Redirect("netframework");  
129:         }  
130:   
131:         protected void cmdsql_Click(object sender, EventArgs e)  
132:         {  
133:             Redirect("sql");  
134:         }  
135:   
136:         protected void cmdAll_Click(object sender, EventArgs e)  
137:         {  
138:             Redirect("all");  
139:         }  
140:   
141:         private void Redirect(string group)  
142:         {  
143:             Log log = new Log();  
144:               
145:             string url = "PracticeTest.aspx?Group=" + group + "&AdditionalOptions=" + hiddenAdditionalOptions.Value + "&TagOptions=" + hiddenTagOptions.Value + "&IsNew=true";  
146:             log.LogLocation = ((UserWeb)Session["userWeb"]).UserLocation.FullLocationName;  
147:             log.LogArea = url;  
148:             log.UserWeb = (UserWeb)Session["userWeb"];  
149:             log.Save(new SqlWrapper());  
150:   
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.