EventmanagementDataContext db = new EventmanagementDataContext();
var v = from user in db.tblUsers select new {user.Name,user.UserID};
DropDownList1.DataSource = v;
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "UserID";
DropDownList1.DataBind();
Tuesday, May 31, 2011
Linq - fetch data from database using linkq
create database "Eventmanagement" in SQL server.
Add table tblUser with fields "username","password","userid"
Add "Linq to SQL class" named "Eventmanagement"
Add table "tbluser" from database "Eventmanagement" to the layout in dbml file created
under app_code folder.
Add a GridView in default page.
Paste the following code in Page Load event
EventmanagementDataContext db = new EventmanagementDataContext();
var v = from user in db.tblUsers select new {user.username, user.password, user.userid};
GridView1.DataSource = v;
GridView1.DataBind();
Add table tblUser with fields "username","password","userid"
Add "Linq to SQL class" named "Eventmanagement"
Add table "tbluser" from database "Eventmanagement" to the layout in dbml file created
under app_code folder.
Add a GridView in default page.
Paste the following code in Page Load event
EventmanagementDataContext db = new EventmanagementDataContext();
var v = from user in db.tblUsers select new {user.username, user.password, user.userid};
GridView1.DataSource = v;
GridView1.DataBind();
Configure Visual Source Safe
1. Install VSS.
2. Configure vss database
3. Create project/website in visual studio.
4. Add to source control by selecting "Add to source control" in right click options.
5. It will create folders in vss database.
6. Check out and check in your files there.
7. If you have your default project folder in "my documents". remove the sln and other files to the project folder you set up.
8. open your sln file and enter with your username and password for vss.
To install the same for client -
1. Map drive the database "srcsafe.ini" file in your vss database folder.
2. Select the same database for your client mnachine.
3. Paste the project in the folder or you can "get latest" the folder from "Microsoft Visual Soursafe" in menu.
Add a new file in client's project and checkin the file.
Get latest your project and get the same file in your solution.
Once you check out the file to modify , client can't do the same at same time, untill you make it done.
2. Configure vss database
3. Create project/website in visual studio.
4. Add to source control by selecting "Add to source control" in right click options.
5. It will create folders in vss database.
6. Check out and check in your files there.
7. If you have your default project folder in "my documents". remove the sln and other files to the project folder you set up.
8. open your sln file and enter with your username and password for vss.
To install the same for client -
1. Map drive the database "srcsafe.ini" file in your vss database folder.
2. Select the same database for your client mnachine.
3. Paste the project in the folder or you can "get latest" the folder from "Microsoft Visual Soursafe" in menu.
Add a new file in client's project and checkin the file.
Get latest your project and get the same file in your solution.
Once you check out the file to modify , client can't do the same at same time, untill you make it done.
Upload File from desktop Application to ftp
My.Computer.Network.UploadFile(OpenFileDialog1.FileName, "ftp://yoursitename.com/www/yourfolder/" + s, "ftpUsername", "ftppassword", True, 4000)
Monday, May 30, 2011
Display video in listview, asp.net c#
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
Panel p = new Panel();
p = (Panel)e.Item.FindControl("panv");
Label lbl = new Label();
string str = "";
HiddenField h = new HiddenField();
h = (HiddenField)e.Item.FindControl("hVideoid");
str = " ";
lbl.Text = str;
p.Controls.Clear();
p.Controls.Add(lbl);
}
{
Panel p = new Panel();
p = (Panel)e.Item.FindControl("panv");
Label lbl = new Label();
string str = "";
HiddenField h = new HiddenField();
h = (HiddenField)e.Item.FindControl("hVideoid");
str = " ";
lbl.Text = str;
p.Controls.Clear();
p.Controls.Add(lbl);
}
Upload video in asp.net , c#
private void UploadVideo()
{
if (FileUpload1.HasFile == true)
{
string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
string[] allowedtypes = new string[] { ".flv" };
if (allowedtypes.Contains(ext))
{
string[] mimetypes = new string[] { "application/x-shockwave-flash", "application/octet-stream", "video/x-flv" };
string filetype = FileUpload1.PostedFile.ContentType;
if (mimetypes.Contains(filetype) == false)
{
// error = "Image is not in the correct format, Please ensure the image is either a JPEG, GIF or PNG";
return;
}
else
{
string filename = Session["StudentID"].ToString() +"_"+ DateTime.Now + ext.ToString();
filename = filename.Replace("/", "").Trim();
filename = filename.Replace(":", "");
filename = filename.Replace(" ", "");
string strpath = "Video/" + filename;
FileUpload1.SaveAs(Server.MapPath("~/forum/Video/") + filename);
}
}
else
{
lblMassage.Text = "Only .FLV format supported";
return;
}
}
else
{
lblMassage.Text = "No file selected.";
return;
}
}
{
if (FileUpload1.HasFile == true)
{
string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
string[] allowedtypes = new string[] { ".flv" };
if (allowedtypes.Contains(ext))
{
string[] mimetypes = new string[] { "application/x-shockwave-flash", "application/octet-stream", "video/x-flv" };
string filetype = FileUpload1.PostedFile.ContentType;
if (mimetypes.Contains(filetype) == false)
{
// error = "Image is not in the correct format, Please ensure the image is either a JPEG, GIF or PNG";
return;
}
else
{
string filename = Session["StudentID"].ToString() +"_"+ DateTime.Now + ext.ToString();
filename = filename.Replace("/", "").Trim();
filename = filename.Replace(":", "");
filename = filename.Replace(" ", "");
string strpath = "Video/" + filename;
FileUpload1.SaveAs(Server.MapPath("~/forum/Video/") + filename);
}
}
else
{
lblMassage.Text = "Only .FLV format supported";
return;
}
}
else
{
lblMassage.Text = "No file selected.";
return;
}
}
Encrypt & Decrypt
Public Function Encrypt1(ByVal toEncrypt As String, ByVal key As String, ByVal useHashing As Boolean) As String
Dim keyArray As Byte()
Dim toEncryptArray As Byte() = UTF8Encoding.UTF8.GetBytes(toEncrypt)
If useHashing = True Then
Dim hashmd5 As New MD5CryptoServiceProvider()
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key))
Else
keyArray = UTF8Encoding.UTF8.GetBytes(key)
End If
Dim tdes As New TripleDESCryptoServiceProvider()
tdes.Key = keyArray
tdes.Mode = CipherMode.ECB
tdes.Padding = PaddingMode.PKCS7
Dim cTransform As ICryptoTransform = tdes.CreateEncryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return (Convert.ToBase64String(resultArray, 0, resultArray.Length))
End Function
Public Function Decrypt1(ByVal toDecrypt As String, ByVal key As String, ByVal useHashing As Boolean) As String
Dim keyArray As Byte()
Dim toEncryptArray As Byte() = Convert.FromBase64String(toDecrypt)
If useHashing = True Then
Dim hashmd5 As New MD5CryptoServiceProvider()
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key))
Else
keyArray = UTF8Encoding.UTF8.GetBytes(key)
End If
Dim tdes As New TripleDESCryptoServiceProvider()
tdes.Key = keyArray
tdes.Mode = CipherMode.ECB
tdes.Padding = PaddingMode.PKCS7
Dim cTransform As ICryptoTransform = tdes.CreateDecryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return UTF8Encoding.UTF8.GetString(resultArray)
End Function
Dim keyArray As Byte()
Dim toEncryptArray As Byte() = UTF8Encoding.UTF8.GetBytes(toEncrypt)
If useHashing = True Then
Dim hashmd5 As New MD5CryptoServiceProvider()
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key))
Else
keyArray = UTF8Encoding.UTF8.GetBytes(key)
End If
Dim tdes As New TripleDESCryptoServiceProvider()
tdes.Key = keyArray
tdes.Mode = CipherMode.ECB
tdes.Padding = PaddingMode.PKCS7
Dim cTransform As ICryptoTransform = tdes.CreateEncryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return (Convert.ToBase64String(resultArray, 0, resultArray.Length))
End Function
Public Function Decrypt1(ByVal toDecrypt As String, ByVal key As String, ByVal useHashing As Boolean) As String
Dim keyArray As Byte()
Dim toEncryptArray As Byte() = Convert.FromBase64String(toDecrypt)
If useHashing = True Then
Dim hashmd5 As New MD5CryptoServiceProvider()
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key))
Else
keyArray = UTF8Encoding.UTF8.GetBytes(key)
End If
Dim tdes As New TripleDESCryptoServiceProvider()
tdes.Key = keyArray
tdes.Mode = CipherMode.ECB
tdes.Padding = PaddingMode.PKCS7
Dim cTransform As ICryptoTransform = tdes.CreateDecryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return UTF8Encoding.UTF8.GetString(resultArray)
End Function
Subscribe to:
Posts (Atom)