-
Notifications
You must be signed in to change notification settings - Fork 0
/
faq.aspx.cs
312 lines (211 loc) · 7.45 KB
/
faq.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class faq : System.Web.UI.Page
{
public SqlConnection con;
public string constr;
public void connection()
{
constr = ConfigurationManager.ConnectionStrings["Grocery"].ToString();
con = new SqlConnection(constr);
con.Open();
}
protected void Page_Load(object sender, EventArgs e)
{
connection();
string query = "select * from tFaq "; //where Email like'" + txtSearch.Text + "%'";
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
da.Fill(ds, "tFaq");
//rpFaq.DataSourceID = null;
rpFaq.DataSource = ds;
rpFaq.DataMember = "tFaq";
rpFaq.DataBind();
//connection();
//string query = "select * from tFaq "; // where Email like'" + txtSearch.Text + "%'";
//SqlCommand com = new SqlCommand(query, con);
//SqlDataReader dr;
//dr = com.ExecuteReader();
//if (dr.HasRows)
//{
// dr.Read();
// rep_bind();
//}
//if (!IsPostBack)
//{
// lbl.Visible = false;
//}
// else
// {
//lblRecord.Text = txtSearch.Text + " Is Not Available in the Records";
//lblRecord.ForeColor = System.Drawing.Color.Red;
// }
}
//private void rep_bind()
//{
// connection();
// string query = "select * from tFaq "; //where Email like'" + txtSearch.Text + "%'";
// SqlDataAdapter da = new SqlDataAdapter(query, con);
// DataSet ds = new DataSet();
// da.Fill(ds, "tFaq");
// //rpFaq.DataSourceID = null;
// rpFaq.DataSource = ds;
// rpFaq.DataMember = "tFaq";
// rpFaq.DataBind();
//}
//protected void btnShowQuestn_Click(object sender, EventArgs e)
//{
// if (ans.Visible != true)
// {
// ans.Visible = true;
// }
// else
// {
// ans.Visible = false;
// }
//}
//protected void DataList1_ItemCommand1(object source, DataListCommandEventArgs e)
//{
// //DataListItem item = (DataListItem)(((Button)(e.CommandSource)).NamingContainer);
// //string text = ((Label)item.FindControl("lblAns")).Text;
// DataListItem item = (DataListItem)(((Button)(e.CommandSource)).NamingContainer);
// Label lbl = ((Label)item.FindControl("lblAns")) as Label;
// if (lbl.Visible !=true)
// {
// lbl.Visible = true;
// }
// else
// {
// lbl.Visible = false;
// }
// }
//protected void btnShowQuestn_Click(object sender, DataListItemEventArgs e)
//{
// foreach (DataListItem item in DataList1.Items)
// {
// Label lbl = (Label)item.FindControl("lblAns");
// // Do what you need to with this label
// if (lbl.Visible != true)
// {
// lbl.Visible = true;
// }
// else
// {
// lbl.Visible = false;
// }
// }
//}
//protected void btnShowQuestn_Click(object sender, EventArgs e)
//{
// foreach (ListViewItem item in lvFaq.Items)
// {
// Label mylabel = (Label)item.FindControl("lblAns");
// mylabel.Visible = true;
// }
protected void btnCntact_Click(object sender, EventArgs e)
{
try
{
if (Page.IsValid)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("joshboluwaji6@gmail.com");
mailMessage.To.Add("joshboluwaji6@gmail.com");
mailMessage.Subject = txtSubject.Text;
mailMessage.Body = "<b>Sender Name : </b>" + txtName.Text + "<br/>"
+ "<b>Sender Email : </b>" + txtEmail.Text + "<br/>"
+ "<b>Phone : </b>" + txtPhone.Text + "<br/>"
+ "<b>Subject : </b>" + txtSubject.Text + "<br/>"
+ "<b>Comments : </b>" + txtComments.Text;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.EnableSsl = true;
smtpClient.Credentials = new
System.Net.NetworkCredential("joshboluwaji6@gmail.com", "Glory2020");
smtpClient.Send(mailMessage);
lblMssg.ForeColor = System.Drawing.Color.Blue;
lblMssg.Text = "Thank you for contacting us";
txtName.Enabled = false;
txtEmail.Enabled = false;
txtComments.Enabled = false;
txtSubject.Enabled = false;
txtPhone.Enabled = false;
btnCntact.Enabled = false;
}
}
catch (Exception ex)
{
// Log the exception information to
// database table or event viewer
lblMssg.ForeColor = System.Drawing.Color.Red;
lblMssg.Text = "Your Message Cannot be Sent. Please try Again...";
}
}
}
//protected void btnShowQuestn_Click(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
//{
// if (ans.Visible != true)
// {
// ans.Visible = true;
// }
// else
// {
// ans.Visible = false;
// }
//}
//private void BindGrid()
//{
// connection();
// {
// using (SqlCommand cmd = new SqlCommand("SELECT * FROM [tFaq] "))
// {
// using (SqlDataAdapter sda = new SqlDataAdapter())
// {
// cmd.Connection = con;
// sda.SelectCommand = cmd;
// using (DataSet ds = new DataSet())
// {
// sda.Fill(ds);
// //GvCust.DataSource = dt;
// // GvCust.DataBind();
// //rpFaq.DataSourceID = null;
// rpFaq.DataSource = ds;
// rpFaq.DataBind();
// }
// }
// }
// //conn.Close();
// }
//}
//private void rep_bind()
//{
// connection();
// string query = "select * from tFaq "; //where Email like'" + txtSearch.Text + "%'";
// SqlDataAdapter da = new SqlDataAdapter(query, con);
// DataSet ds = new DataSet();
// da.Fill(ds);
// rpFaq.DataSourceID = null;
// rpFaq.DataSource = ds;
// rpFaq.DataBind();
//}
//protected void btnSearch_Click(object sender, EventArgs e)
//{
// connection();
// string query = "select * from Customers where Email like'" + txtSearch.Text + "%'";
// SqlCommand com = new SqlCommand(query, con);
// SqlDataReader dr;
// dr = com.ExecuteReader();
// if (dr.HasRows)
// {
// dr.Read();
// rep_bind();
// }
// else
// {
// lblRecord.Text = txtSearch.Text + " Is Not Available in the Records";
// lblRecord.ForeColor = System.Drawing.Color.Red;
// }