I created a tool to export this JSON to delicious.
Goto http://grnotestodelicious.codeplex.com/ for the tool & source code
public class ExcelItem
{
[ExcelColumnIndex(Index=0)]
public string Name {get;set;}
[ExcelColumnIndex(Index=1)]
public string Phone {get;set;}
}
Importer<ExcelItem> _Importer = new Importer<ExcelItem>();
List<ExcelItem> data=_Importer.ParseExcel("FILE PATH", "sheet1");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.OleDb;
namespace ExcelImporter
{
//3-may-2010 Priyan R
public class Importerwhere T : new()
{
public ListParseExcel(string filePath,string sheetName)
{
string tempFile, connectionString, query;
OleDbConnection con = null;
OleDbDataReader reader = null;
OleDbCommand command = null;
//
connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
filePath + @";Extended Properties=""Excel 8.0;HDR=YES;""";
query = "SELECT * FROM [" + sheetName + "$]";
//
var ret = new List();
try
{
con = new OleDbConnection(connectionString);
con.Open();
command = new OleDbCommand(query, con);
reader = command.ExecuteReader();
while (reader.Read())
{
var entry = new T();
foreach (var property in entry.GetType().GetProperties())
{
var attributes = property.GetCustomAttributes(false);
var attribute = property.GetCustomAttributes(false)
.Where(p => p.GetType() == typeof(ExcelColumnIndex)).FirstOrDefault(); ;
if (attribute != null)
{
property.SetValue(entry, reader[((ExcelColumnIndex)attribute).Index].ToString(), null);
}
}
ret.Add(entry);
}
}
catch
{
throw;
}
finally
{
if (con != null && con.State == System.Data.ConnectionState.Open)
{
con.Close();
}
}
return ret;
}
}
public class ExcelColumnIndex : Attribute
{
public int Index { get; set; }
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if(cbValidate.Checked)
{
//validate
Validate("vgSubmit");
}
if (!IsValid) return;
lblMsg.Text = "Passed validation";
}
function CheckValidation() {
var cbValidate = document.getElementById('<%=cbValidate.ClientID %>');
var flag = true;
if (cbValidate.checked) {
if (!Page_ClientValidate("vgSubmit"))
flag = false;
}
else {
Page_ClientValidate("vgDummy")
}
return flag;
}
In asp.net 2.0 we used Context.RewritePath() or other URL rewrite modules. With asp.net 3.5 its easy to do. I did it for my blog for better SEO.
I am going to rewrite blogs/Posts/{BlogPostID}/{*BlogPostTitle}
I implemented a generic IRouteHandler , it will copy url parameters( eg: BlogPostID,BlogPostTitle ) to http context item collection, so i can URL rewrite any page , without modifying IRouteHandler implementation.
using System;
using System.Web;
using System.Web.Routing;
using System.Web.Compilation;
using System.Web.UI;
public class SiteRouteHandler : IRouteHandler
{
//30 june 2009 Priyan R
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
Page page;
page = BuildManager.CreateInstanceFromVirtualPath(PageVirtualPath, typeof(Page)) as Page;
foreach (var item in requestContext.RouteData.Values)
{
HttpContext.Current.Items["qparam." + item.Key] = item.Value;
}
return page;
}
public string PageVirtualPath { get; set; }
}
In global.asax added
routes.Add(
"BlogPost",
new Route("Blogs/Posts/{BlogPostID}/{*BlogPostTitle}",
new SiteRouteHandler() { PageVirtualPath = "~/Blogs/Details.aspx" })
);
So in Details.aspx I can read the parameters
Context.Items["qparam.BlogPostID"].ToString()
Context.Items["qparam.BlogPostTitle"].ToString()
Check the code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
namespace RssFeed
{
//12-aug-2009 Priyan R
public class RssParser
{
public RssParser()
{
Items = new List<RssItem>();
}
public RssParser(string url):this()
{
URL = url;
}
#region Methods
public void Parse()
{
XDocument doc = XDocument.Load(URL, LoadOptions.None);
Items = (from t in doc.Descendants("item")
select new RssItem()
{
Title = t.Element("title").Value,
Description = t.Element("description").Value,
Link = t.Element("link").Value
}
).ToList();
}
#endregion
#region properties
public string URL { get; set; }
public List<RssItem> Items { get; set; }
#endregion
}
#region RSS Item Class
public class RssItem
{
public string Title{ get; set; }
public string Description { get; set; }
public string Link { get; set; }
}
#endregion
}
protected void odSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.ReturnValue.GetType() == typeof(Int32))
{
ViewState["TotalCount"] = e.ReturnValue;
}
}