using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Net.Mail;
public partial class kalenderreminder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//try
//{
// DataTable dt = GetEvents().Tables[0];
// DataTable dt2 = new DataTable();
// if (dt != null)
// {
// MailMessage msgMail = new MailMessage();
// string s = null;
// foreach (DataRow dr in dt.Rows)
// {
// dt2 = GetUser(dr["Worker"].ToString()).Tables[0];
// s = dr["EventDesc"].ToString();
// foreach(DataRow DataRow in dt2.Rows){
// msgMail.To = DataRow["E_MAIL"].ToString();
// msgMail.From = "noreply@mail.dk";
// msgMail.Subject = "New events from your personal calender...";
// msgMail.BodyFormat = MailFormat.Text;
// //msgMail.Attachments.Add( //new MailAttachment(FileUpload1.ToString()));
// msgMail.Body = "Event: " "\n\n" dr["EventDesc"].ToString() "\r\n" dr["EventDate"].ToString() "\n\n\n";
// SmtpMail.SmtpServer = "smtp.something.com";
// if (s != null && s != "")
// {
// //SmtpMail.Send(msgMail);
// }
//
//
// }
// }
// AddRemided();
// }
//}catch { } // EXAMPLE IF THERE WAS ONLY 1 USER
DataTable dt = new DataTable();
dt = GetWorkers().Tables[0];
string loop = ";"; //maybe list or arraylist
bool go = false;
foreach (DataRow dr in dt.Rows) //while top 1 fra db
{
if (dt.Rows.Count == 0)
break;
foreach(string s in loop.Split(';')){
if(s == dr["Worker"].ToString()){
go = true;
break;
}
}
if (go == false)
{
MailMessage msgMail = new MailMessage();
try
{
DataTable tempdt = GetUserEmail(dr["Worker"].ToString()).Tables[0];
if (tempdt.Rows.Count != 0)
{
foreach (DataRow tempdr in tempdt.Rows)
{
if (tempdr["E_MAIL"].ToString() != "")
msgMail.To.Add(new MailAddress(tempdr["E_MAIL"].ToString()));
else
throw new System.InvalidOperationException("No user found in DB!");
}
}else
throw new System.InvalidOperationException("No rows found in DB!");
}
catch
{
DataTable tempdt = new DataTable();
tempdt = GetAllUsers().Tables[0];
foreach (DataRow tempdr in tempdt.Rows)
msgMail.To.Add(new MailAddress(tempdr["E_MAIL"].ToString()));
}
msgMail.From = new MailAddress("noreply@mail.dk");
msgMail.Subject = "New events from your event calender...";
msgMail.BodyEncoding = System.Text.Encoding.UTF8;
msgMail.IsBodyHtml = false;
msgMail.Priority = MailPriority.High;
//msgMail.Attachments.Add( //new MailAttachment(FileUpload1.ToString()));
string events = null;
{
DataTable tempdt = GetUserEvents(dr["Worker"].ToString()).Tables[0];
foreach (DataRow tempdr in tempdt.Rows)
{
events = tempdr["EventDesc"].ToString();
if (events != null && events != "")
{
msgMail.Body = "Event: " "\n\n" tempdr["EventDesc"].ToString() "\r\n" tempdr["EventDate"].ToString() "\n\n\n";
}
else
{
msgMail.Body = "\r\n" "Someone wrote empty event..." "\n\n\n";
}
}
}
SmtpClient SmtpServer = new SmtpClient("smtp.something.com");
if (msgMail.Body != null && msgMail.Body != "")
{
SmtpServer.Send(msgMail);
AddRemided(dr["Worker"].ToString());
}
loop = dr["Worker"].ToString() ";";
go = false;
dt = GetWorkers().Tables[0];
}
}
}
private bool AddRemided(string user)
{
//You can Add Those Event In Same Dataset Again Or use Any One Of The Way
//i.e. Store Your Event In DataBase Or Store It In Dataset
MSSQLConn conn = new MSSQLConn();
SqlConnection sqlcn = new SqlConnection(conn.MSSQLString());
SqlCommand sqlcmd = new SqlCommand("Update kalender set mailreminder = 1 where convert(date, EventDate) = convert(datetime,(CONVERT(char(10), GETDATE(), 103)),103) and Worker = '" user "'", sqlcn);
sqlcn.Open();
sqlcmd.CommandType = CommandType.Text;
int _record;
_record = sqlcmd.ExecuteNonQuery();
if (_record > 0)
return true;
else
return false;
}
private DataSet GetWorkers()
{
try
{
MSSQLConn conn = new MSSQLConn();
SqlConnection sqlcn = new SqlConnection(conn.MSSQLString());
DataSet sqlds = new DataSet();
SqlDataAdapter sqlda = new SqlDataAdapter("Select Worker from kalender where convert(date, EventDate) = " "convert(datetime," "(CONVERT(char(10), GETDATE(), 103))" ",103)" " and mailreminder is null or mailreminder = 0 and EventDesc is not null", sqlcn);
sqlda.Fill(sqlds);
return sqlds;
}
catch (Exception ex)
{
//Response.Write(ex.Message.ToString());
}
return null;
}
private DataSet GetUserEvents(string user)
{
try
{
MSSQLConn conn = new MSSQLConn();
SqlConnection sqlcn = new SqlConnection(conn.MSSQLString());
DataSet sqlds = new DataSet();
SqlDataAdapter sqlda = new SqlDataAdapter("Select * from kalender where convert(date, EventDate) = " "convert(datetime," "(CONVERT(char(10), GETDATE(), 103))" ",103)" " and (mailreminder is null or mailreminder = 0) and Worker = '" user "'", sqlcn);
sqlda.Fill(sqlds);
return sqlds;
}
catch (Exception ex)
{
//Response.Write(ex.Message.ToString());
}
return null;
}
private DataSet GetAllUsers()
{
try
{
MSSQLConn conn = new MSSQLConn();
SqlConnection sqlcn = new SqlConnection(conn.MSSQLString());
DataSet sqlds = new DataSet();
SqlDataAdapter sqlda = new SqlDataAdapter("Select E_MAIL from Log_Users", sqlcn);
sqlda.Fill(sqlds);
return sqlds;
}
catch (Exception ex)
{
//Response.Write(ex.Message.ToString());
}
return null;
}
private DataSet GetUserEmail(string user)
{
try
{
MSSQLConn conn = new MSSQLConn();
SqlConnection sqlcn = new SqlConnection(conn.MSSQLString());
DataSet sqlds = new DataSet();
SqlDataAdapter sqlda = new SqlDataAdapter("Select E_MAIL from Log_Users where Username = '" user "'", sqlcn);
sqlda.Fill(sqlds);
return sqlds;
}
catch (Exception ex)
{
//Response.Write(ex.Message.ToString());
}
return null;
}
}
C#:
void LinkButton_Click(object sender, EventArgs e)
{
LinkButton lbtnSender = (LinkButton)sender;
DoAccordionPane(lbtnSender.ID.ToString());
}
public void DoAccordionPane(string lnkbtnID)
{
DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory.ToString() "rootfolder/folder/" lnkbtnID "/");
FileInfo[] rgFiles = di.GetFiles("*.txt");
foreach (FileInfo fi in rgFiles)
{
AccordionPane pane2 = new AccordionPane();
pane2.HeaderContainer.Controls.Add(new LiteralControl(lnkbtnID " " fi.ToString().Split('.')[0]));
List result = new List();
StreamReader re;
using (re = new StreamReader(AppDomain.CurrentDomain.BaseDirectory.ToString() "rootfolder/folder/" lnkbtnID "/" fi.ToString(), new System.Text.UTF7Encoding()))
{
string input = null;
while ((input = re.ReadLine()) != null)
{
result.Add(input);
}
re.Close();
}
foreach (string s in result)
{
pane2.ContentContainer.Controls.Add(new LiteralControl(s));
MyAccordion.Controls.Add(pane2);
}
}
}
HTML:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
//This class has to be placed in App_Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Reflection;
namespace WebsiteThumbnail
{
public class WebsiteThumbnailImageGenerator
{
public static Bitmap GetWebSiteThumbnail(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)
{
WebsiteThumbnailImage thumbnailGenerator = new WebsiteThumbnailImage(Url, BrowserWidth, BrowserHeight, ThumbnailWidth, ThumbnailHeight);
return thumbnailGenerator.GenerateWebSiteThumbnailImage();
}
private class WebsiteThumbnailImage
{
public WebsiteThumbnailImage(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)
{
this.m_Url = Url;
this.m_BrowserWidth = BrowserWidth;
this.m_BrowserHeight = BrowserHeight;
this.m_ThumbnailHeight = ThumbnailHeight;
this.m_ThumbnailWidth = ThumbnailWidth;
}
private string m_Url = null;
public string Url
{
get
{
return m_Url;
}
set
{
m_Url = value;
}
}
private Bitmap m_Bitmap = null;
public Bitmap ThumbnailImage
{
get
{
return m_Bitmap;
}
}
private int m_ThumbnailWidth;
public int ThumbnailWidth
{
get
{
return m_ThumbnailWidth;
}
set
{
m_ThumbnailWidth = value;
}
}
private int m_ThumbnailHeight;
public int ThumbnailHeight
{
get
{
return m_ThumbnailHeight;
}
set
{
m_ThumbnailHeight = value;
}
}
private int m_BrowserWidth;
public int BrowserWidth
{
get
{
return m_BrowserWidth;
}
set
{
m_BrowserWidth = value;
}
}
private int m_BrowserHeight;
public int BrowserHeight
{
get
{
return m_BrowserHeight;
}
set
{
m_BrowserHeight = value;
}
}
public Bitmap GenerateWebSiteThumbnailImage()
{
Thread m_thread = new Thread(new ThreadStart(_GenerateWebSiteThumbnailImage));
m_thread.SetApartmentState(ApartmentState.STA);
m_thread.Start();
m_thread.Join();
return m_Bitmap;
}
private void _GenerateWebSiteThumbnailImage()
{
WebBrowser m_WebBrowser = new WebBrowser();
m_WebBrowser.ScrollBarsEnabled = false;
m_WebBrowser.Navigate(m_Url);
m_WebBrowser.DocumentCompleted = new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
while (m_WebBrowser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
m_WebBrowser.Dispose();
}
private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser m_WebBrowser = (WebBrowser)sender;
m_WebBrowser.ClientSize = new Size(this.m_BrowserWidth, this.m_BrowserHeight);
m_WebBrowser.ScrollBarsEnabled = false;
m_Bitmap = new Bitmap(m_WebBrowser.Bounds.Width, m_WebBrowser.Bounds.Height);
m_WebBrowser.BringToFront();
m_WebBrowser.DrawToBitmap(m_Bitmap, m_WebBrowser.Bounds);
m_Bitmap = (Bitmap)m_Bitmap.GetThumbnailImage(m_ThumbnailWidth, m_ThumbnailHeight, null, IntPtr.Zero);
}
}
}
}
//This class is showed how to use it:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
namespace WebsiteThumbnail
{
public partial class WebsiteThumbnailImagePage : System.Web.UI.Page
{
protected void btnShowThumbnailImage_Click(object sender, EventArgs e)
{
string address = "http://" txtWebsiteAddress.Text;
int width = Int32.Parse(txtWidth.Text);
int height = Int32.Parse(txtHeight.Text);
Bitmap bmp = WebsiteThumbnailImageGenerator.GetWebSiteThumbnail(address, 1024, 768, width, height);
bmp.Save(Server.MapPath("~") "/thumbnail/thumbnail.jpg");
imgWebsiteThumbnailImage.ImageUrl = "~/thumbnail/thumbnail.jpg";
imgWebsiteThumbnailImage.Visible = true;
}
}
}
//download this code here:
//http://simpa.dk/smr/Examples/asp.net/thumbnail.zip
asp.net How to export datatable to csv and xml
<%@ Page language="c#" AutoEventWireup="true" %>
<%@ Import NameSpace="System" %>
<%@ Import NameSpace="System.Data" %>
Export to XML/CSV
Export dataview (XML)
Export dataview (CSV)
Here is the code for export.aspx:
<%@ Page language="c#" AutoEventWireup="true" %>
<%@ Import NameSpace="System.IO" %>
<%@ Import NameSpace="System" %>
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Web" %>
<%@ Import NameSpace="System.Text" %>
Step 1.
Step 2.
/*body onload="$(document).ready(function() { initSession(true); })"*/
Step 3.
Step 4.
Step 5.
[WebMethod(EnableSession = true)]
public static void PokeServerPage()
{
//=> Poke server page to keep session alive...
}
Step 6.
Security considerations...
step 1. Firstly create facebook app you will need the app id and app secret and setup website URL, domain etc...
step 2. create this class in App_Code folder:
using System.Configuration;
using System.Web;
public class fbConnect
{
public fbConnect()
{
}
public static bool isConnected()
{
return (SessionKey != null && UserID != -1);
}
public static string ApiKey
{
get
{
return ConfigurationManager.AppSettings["APIKey"];
}
}
public static string SecretKey
{
get
{
return ConfigurationManager.AppSettings["Secret"];
}
}
public static string SessionKey
{
get
{
return GetFacebookCookie("session_key");
}
}
public static int UserID
{
get
{
int userID = -1;
int.TryParse(GetFacebookCookie("user"), out userID);
return userID;
}
}
private static string GetFacebookCookie(string cookieName)
{
string retString = null;
string fullCookie = ApiKey + "_" + cookieName;
if (HttpContext.Current.Request.Cookies[fullCookie] != null)
retString = HttpContext.Current.Request.Cookies[fullCookie].Value;
return retString;
}
}
step 3. Create Default.aspx or Index.aspx on client side insert:
Step 4. In Default.aspx.cs insert:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using facebook;
using facebook.web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (fbConnect.isConnected()) // Check if this application is authenticated
{
API api = new API();
api.ApplicationKey = fbConnect.ApiKey;
api.SessionKey = fbConnect.SessionKey;
api.Secret = fbConnect.SecretKey;
api.uid = fbConnect.UserID;
// hide the facebook button
pnlLogin.Visible = false;
try // be careful using try catch because we always want to find the error...
{
//Get the data of the signed user.
string fullName = api.users.getInfo().first_name.ToUpper() + " " + api.users.getInfo().last_name.ToUpper();
lblMessage.Text = "You are login as " + fullName + " ID: " + api.users.getInfo().uid;
imgPic.ImageUrl = api.users.getInfo().pic_big;
Response.Redirect("Menu.aspx");
}
catch { pnlLogin.Visible = true; }
}
else
{
pnlLogin.Visible = true;
}
}
}
Step 5. Then you need to add Cross Domain Site:
Step 6. This is the last step here you need to add appID, appSecret and callbackUrl in web.config
Download the binaries here "http://simpa.dk/FacebookLogin/bin.zip"
Happy Coding...!
step 1. Firstly create facebook app you will need the app id and app secret and setup website URL, domain etc...
step 2. create this class in App_Code folder:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;
public class ConnectAuthentication
{
public ConnectAuthentication()
{
}
public static bool isConnected()
{
return (SessionKey != null && UserID != -1);
}
public static string ApiKey
{
get
{
return ConfigurationManager.AppSettings["APIKey"];
}
}
public static string SecretKey
{
get
{
return ConfigurationManager.AppSettings["Secret"];
}
}
public static string SessionKey
{
get
{
return GetFacebookCookie("session_key");
}
}
public static int UserID
{
get
{
int userID = -1;
int.TryParse(GetFacebookCookie("user"), out userID);
return userID;
}
}
private static string GetFacebookCookie(string cookieName)
{
string retString = null;
string fullCookie = ApiKey + "_" + cookieName;
if (HttpContext.Current.Request.Cookies[fullCookie] != null)
retString = HttpContext.Current.Request.Cookies[fullCookie].Value;
return retString;
}
}
step 3. Create Default.aspx or Index.aspx on client side insert:
Step 4. In Default.aspx.cs insert:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Facebook.Schema;
using Facebook.Winforms.Components;
using Facebook.Rest;
public partial class facebooklogin3010_Default : System.Web.UI.Page
{
Facebook.Web.FbmlControls.PromptPermission prompter = new Facebook.Web.FbmlControls.PromptPermission();
protected string apiKey;
protected void Page_Load(object sender, EventArgs e)
{
apiKey = ConnectAuthentication.ApiKey;
if (ConnectAuthentication.isConnected())
{
Facebook.Session.ConnectSession session = new Facebook.Session.ConnectSession(ConnectAuthentication.ApiKey, ConnectAuthentication.SecretKey);
try // be careful using try catch because we always want to find the error...
{
session.UserId = ConnectAuthentication.UserID;
Facebook.Rest.Api api = new Facebook.Rest.Api(session);
//Display user data captured from the Facebook API.
Facebook.Schema.user user = api.Users.GetInfo();
string fullName = user.first_name + " " + user.last_name;
Panel1.Visible = true;
Label1.Text = fullName + " ID: " + user.uid;
imgPic.ImageUrl = user.pic_big.ToString();
}
catch(Exception ex)
{
//Label1.Text = ex.Message;
//return;
//session.SessionExpires = true;
//session.Logout();
//Response.Redirect("http://simpa.dk/facebooklogin3010/");
}
}
else
{
//Facebook Connect not authenticated, proceed as usual.
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (ConnectAuthentication.isConnected())
{
FacebookService fbService = new FacebookService();
attachment attach = new attachment();
attach.caption = "Check this out...";
attach.description = "Posting from my Facebook development App";
attach.href = "http://simpa.dk/facebooklogin3010";
attach.name = "Attach my web link via FacebookAPI";
attachment_media attach_media = new attachment_media();
attach_media.type = attachment_media_type.image;
attachment_media_image image = new attachment_media_image();
image.type = attachment_media_type.image;
image.href = "http://simpa.dk/";
image.src = "http://simpa.dk/default/item1.png";
List attach_media_list = new List();
attach_media_list.Add(image);
attach.media = attach_media_list;
attachment_property attach_prop = new attachment_property();
/* action links */
List actionlink = new List();
action_link al1 = new action_link();
al1.href = "http://simpa.dk/";
al1.text = "simpa";
actionlink.Add(al1);
Facebook.Session.ConnectSession session = new Facebook.Session.ConnectSession(ConnectAuthentication.ApiKey, ConnectAuthentication.SecretKey);
session.UserId = ConnectAuthentication.UserID;
Facebook.Rest.Api api = new Facebook.Rest.Api(session);
//Display user data captured from the Facebook API.
string publishAccess = api.ExtendedPermissionUrl(Facebook.Schema.Enums.ExtendedPermissions.publish_stream);
api.Stream.Publish(TextBox1.Text, attach, actionlink, fbService.uid.ToString(), 0);
}
else
{
//Facebook Connect not authenticated, proceed as usual.
}
}
private static Uri GetExtendedPermissionUrl(Enums.ExtendedPermissions permission)
{
return new Uri(String.Format("http://www.facebook.com/authorize.php?api_key={0}&v=1.0&ext_perm={1}", ConnectAuthentication.ApiKey, permission));
}
protected void Button2_Click(object sender, EventArgs e)
{
Enums.ExtendedPermissions perm;
perm = Enums.ExtendedPermissions.publish_stream;
Uri uri = GetExtendedPermissionUrl(perm);
Response.Redirect(uri.ToString());
}
}
Step 5. Then you need to add Cross Domain Site:
Step 6. This is the last step here you need to add appID, appSecret and callbackUrl in web.config
You can test this at "http://simpa.dk/facebooklogin3010"
download the binaries here "http://simpa.dk/facebooklogin3010/SDK_Binaries.zip"
Happy Coding...!
protected void Page_Load(object sender, EventArgs e)
{
var extendedPermissions = ConfigurationManager.AppSettings["extendedPermissions"].Split(',');
if (!FacebookWebContext.Current.IsAuthorized(extendedPermissions))
{
// this sample actually does not make use of FormsAuthentication,
// besides redirecting to the proper login url defined in web.config
// this will also automatically add ReturnUrl.
FormsAuthentication.RedirectToLoginPage();
}
else
{
// checking IsPostBack may reduce the number of requests to Facebook server.
if (!IsPostBack)
{
var fb = new FacebookWebClient();
dynamic me = fb.Get("me");
imgProfilePic.ImageUrl = string.Format("https://graph.facebook.com/{0}/picture", me.id);
lblName.Text = me.name;
lblFirstName.Text = me.first_name;
lblLastName.Text = me.last_name;
LabelID.Text = me.id;
}
}
}
protected void btnPostToWall_Click(object sender, EventArgs e)
{
var fb = new FacebookWebClient();
dynamic parameters = new ExpandoObject();
parameters.message = txtMessage.Text;
try
{
dynamic id = fb.Post("me/feed", parameters);
lblPostMessageResult.Text = "Message posted successfully";
txtMessage.Text = string.Empty;
}
catch (FacebookApiException ex)
{
lblPostMessageResult.Text = ex.Message;
}
}
//you can download this example i section Projects
server side:
public partial class _Default : System.Web.UI.Page
{
protected AccordionPane pane;
protected SlideShowExtender sse;
protected Button Btn_Next;
protected Button Btn_Play;
protected Button Btn_Previous;
protected Label lblImageDescription;
protected Image Image1;
protected int i;
protected void Page_Load(object sender, EventArgs e)
{
i = -1;
//try
//{
DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory.ToString() + "images/");
DirectoryInfo[] tempdi = di.GetDirectories();
foreach (DirectoryInfo dirinfo in tempdi)
{
i++;
pane = new AccordionPane();
pane.HeaderContainer.Controls.Add(new LiteralControl(dirinfo.ToString()));
sse = new SlideShowExtender();
Btn_Next = new Button();
Btn_Next.Width = 64;
Btn_Next.Height = 26;
Btn_Next.Text = "Next";
Btn_Next.ID = UniqueID + "1148";
Btn_Previous = new Button();
Btn_Previous.ID = UniqueID + "1185";
Btn_Previous.Width = 62;
Btn_Previous.Height = 25;
Btn_Previous.Text = "Previous";
Btn_Play = new Button();
Btn_Play.ID = UniqueID + "1152";
sse.AutoPlay = true;
lblImageDescription = new Label();
lblImageDescription.ID = UniqueID + "1119";
sse.ImageDescriptionLabelID = UniqueID + "1119";
sse.Loop = true;
sse.NextButtonID = UniqueID + "1148";
sse.PreviousButtonID = UniqueID + "1185";
sse.PlayButtonID = UniqueID + "1152";
sse.PlayButtonText = "Play";
//sse.SlideShowServicePath = "webs.asmx";
sse.SlideShowServiceMethod = "GetSlides1";
sse.ContextKey = i.ToString();
sse.StopButtonText = "Stop";
Image1 = new Image();
Image1.Height = 316;
Image1.Width = 388;
Image1.ID = UniqueID + "1164";
sse.TargetControlID = UniqueID + "1164";
pane.ContentContainer.Controls.Add(lblImageDescription);
pane.ContentContainer.Controls.Add(Image1);
pane.ContentContainer.Controls.Add(Btn_Previous);
pane.ContentContainer.Controls.Add(Btn_Play);
pane.ContentContainer.Controls.Add(Btn_Next);
pane.ContentContainer.Controls.Add(sse);
MyAccordion.Controls.Add(pane);
}
}
}
client side:
and place this where you want the accordions to appear on the page:
protected void LinkButton1_Click(object sender, EventArgs e)
{
Label1.Text = "";
List result = new List();
StreamReader re;
using (re = new StreamReader(AppDomain.CurrentDomain.BaseDirectory.ToString() "filename.txt", new System.Text.UTF7Encoding()))
{
string input = null;
while ((input = re.ReadLine()) != null)
{
result.Add(input);
}
re.Close();
}
foreach (string s in result)
//Do something here...
Label1.Text = s;
}
John
Smith
James
White
XmlDocument xml = new XmlDocument();
xml.LoadXml(myXmlString); // suppose that myXmlString contains "...", if this succeds then you know if it is valid xml or not
XmlNodeList xnList = xml.SelectNodes("/Names/Name");
foreach (XmlNode xn in xnList)
{
string firstName = xn["FirstName"].InnerText;
string lastName = xn["LastName"].InnerText;
Console.WriteLine("Name: {0} {1}", firstName, lastName);
}
MailMessage msgMail = new MailMessage();
msgMail.To = "yourmail@hotmail.com";
msgMail.From = mail.Text;
msgMail.Subject = subject.Text;
msgMail.BodyFormat = MailFormat.Text;
//msgMail.Attachments.Add(
//new MailAttachment(FileUpload1.ToString()));
strBody = "Name: " name.Text " \n " message.Text;
msgMail.Body = strBody;
SmtpMail.SmtpServer = "yoursmtpserver";
try
{
SmtpMail.Send(msgMail);
}
catch { this.MessageLabel.Text = "An error has occured on the mailserver, please try again after few seconds..."; }
asp.net How to sort and get 5 latest threads
//get all dates and sort
List threadcreated = new List();
string splitstring = null;
bool exists = false;
DirectoryInfo dilist = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory.ToString() + dir);
DirectoryInfo[] tempdirlist = dilist.GetDirectories();
foreach (DirectoryInfo dirinfo in tempdirlist)
{
if (dirinfo.ToString() != "css" && dirinfo.ToString() != "design" && dirinfo.ToString() != "imgs")
{
try
{
//////Open the XML doc
System.Xml.XmlDocument myXmlDocument5latest = new System.Xml.XmlDocument();
myXmlDocument5latest.Load(AppDomain.CurrentDomain.BaseDirectory.ToString() + dirinfo.Parent + "/" + dirinfo.ToString() + "/year.xml");
System.Xml.XmlNode myXmlNode5latest = myXmlDocument5latest.SelectSingleNode("configuration / appSettings");
//////Create new XML element and populate its attributes
foreach (XmlNode childNode in myXmlNode5latest)
{
if (childNode.Attributes["key"].Value == "YearKey")
splitstring = childNode.Attributes["value"].Value;
}
splitstring = splitstring.Split('k')[1];
splitstring = splitstring.Split(':')[1];
DateTime MyDateTime = new DateTime();
MyDateTime = Convert.ToDateTime(splitstring);
//MyDateTime = DateTime.ParseExact(splitstring, "dd-MM-yyyy HH:mm:ss", null);
if (threadcreated.Count == 0)
threadcreated.Add(MyDateTime);
else
{
foreach (DateTime dtnomultiple in threadcreated)
{
if (MyDateTime.Equals(dtnomultiple))
{
exists = true;
break;
}
else
{
exists = false;
break;
}
}
if (!exists)
{
threadcreated.Add(MyDateTime);
}
}
}
catch { }
}
}
threadcreated.Sort();
threadcreated.Reverse();
if (threadcreated.Count > 5)
{
for (int i = threadcreated.Count - 1; i < threadcreated.Count; i--)
{
threadcreated.RemoveAt(i);
if (threadcreated.Count < 6)
{
break;
}
}
}
//getall dates and sort end
int counter = 0;
string month = null;
string day = null;
foreach (DateTime dt in threadcreated)
{
if (dt.Month < 10)
month = "0" + dt.Month;
else
month = dt.Month.ToString();
if (dt.Day < 10)
day = "0" + dt.Day;
else
day = dt.Day.ToString();
string dtstring = day + "/" + month + "/" + dt.Year;
foreach (DirectoryInfo dirinfo2 in tempdirlist)
{
if (dirinfo2.ToString() != "css" && dirinfo2.ToString() != "design" && dirinfo2.ToString() != "imgs")
{
string splitstringcheck2 = null;
//////Open the XML doc
System.Xml.XmlDocument myXmlDocument5latest2 = new System.Xml.XmlDocument();
myXmlDocument5latest2.Load(AppDomain.CurrentDomain.BaseDirectory.ToString() + dirinfo2.Parent + "/" + dirinfo2.ToString() + "/year.xml");
System.Xml.XmlNode myXmlNode5latest2 = myXmlDocument5latest2.SelectSingleNode("configuration / appSettings");
//////Create new XML element and populate its attributes
foreach (XmlNode childNode in myXmlNode5latest2)
{
if (childNode.Attributes["key"].Value == "YearKey")
splitstringcheck2 = childNode.Attributes["value"].Value;
}
splitstringcheck2 = splitstringcheck2.Split('k')[1];
splitstringcheck2 = splitstringcheck2.Split(':')[1];
string[] s2 = splitstringcheck2.Split('-');
string comparestring2 = s2[0] + "/" + s2[1] + "/" + s2[2];
if (dtstring.Equals(comparestring2.Trim()) && counter < 5)
{
lbtn = new LinkButton();
lbtn.ID = dirinfo2.ToString();
lbtn.Text = dirinfo2.ToString() + "
";
lbtn.Click += new EventHandler(LinkButton_Click);
PanelPopUp.Controls.Add(lbtn);
counter++;
//break;
}
}
}
}
asp.net How to use keyboard events in asp net and javascript
//In body of your page add this:
//body onkeypress="keypress(event)"
then add this script: