//Check folder is exist
DirectoryInfo dInfo = new DirectoryInfo
(Server.MapPath( strMediaFileSavePath));
//Create Folder and add files
if (!dInfo.Exists)
{
//dInfo.CreateSubdirectory("@"+strMediaFileSavePath);
System.IO.Directory.CreateDirectory
(Server.MapPath(strMediaFileSavePath));
if (this.AddVideo())
{
return true;
}
else
{
return false;
}
}
Friday, February 29, 2008
Tuesday, February 26, 2008
Create a client javascript popup using client script manager C#- Sanjeewa Sapuman
ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "< script language='javascript' > alert('Video File already exist from the server.');</script >");
Creating a Web streaming movie pager using C# and javascript- Sanjeewa Sapumana
//play a movie
//java script windows media player calling by java script
function SetMovie(mpath)
{
//var mediaName="myVideoName";
alert("Declared variables");
if (mpath == " ")
{
alert("apath is a empty");
}
else
document.getElementById('VideoPlayer').URL=mpath;
alert(document.getElementById('VideoPlayer').URL);
document.getElementById('VideoPlayer').controls.play();
alert("now video is playing");
return false;
}
//Defining the windows media player object in html code
< object type="application/x-oleobject" width="421" height="248" id="VideoPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
< param name="autostart" value="True" / >
< param name="showcontrols" value="false" / >
//in this case wer taking the url from the datagr id link list
< !--< param name="src" value="MediaFiles//YourMovie.wmv" / >-- >
< /object >
//datra grid databinding
protected void gvAvailableVideos_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lbtnVideoFile = ((LinkButton)e.Row.Cells[0].FindControl("lbtnVideoFile"));
if (lbtnVideoFile != null)
{
lbtnVideoFile.Text = gvAvailableVideos.DataKeys[rowno]["VideoFileName"].ToString();
DataView dv = DsMediaFiles.Tables[0].DefaultView;
dv.Sort = "id";
int rowId = dv.Find(gvAvailableVideos.DataKeys[rowno]["Id"]);
string VideoPath=string.Empty;
if(rowId != -1)
{
VideoPath = dv[rowId]["VideoPath"].ToString();
lbtnVideoFile.Attributes.Add("OnClick", "return SetMovie('" + VideoPath + "')");
}
}
rowno += 1;
}
//datagrid handiling html view
< asp:GridView ID="gvAvailableVideos" runat="server" Width="100%" AllowPaging="True" OnRowDataBound="gvAvailableVideos_RowDataBound" AutoGenerateColumns="False" DataKeyNames="Id,VideoFileName" >
< Columns >
< asp:TemplateField HeaderText="VideoFileName" >
< ItemTemplate >
< asp:LinkButton ID="lbtnVideoFile" CommandArgument='< %# Eval("VideoFileName")% >' runat="server" > </asp:LinkButton >
< /ItemTemplate >
< /asp:TemplateField >
< asp:BoundField DataField="AttachmentName" HeaderText="Attachment Name" / >
< /Columns >
< /asp:GridView >
//java script windows media player calling by java script
function SetMovie(mpath)
{
//var mediaName="myVideoName";
alert("Declared variables");
if (mpath == " ")
{
alert("apath is a empty");
}
else
document.getElementById('VideoPlayer').URL=mpath;
alert(document.getElementById('VideoPlayer').URL);
document.getElementById('VideoPlayer').controls.play();
alert("now video is playing");
return false;
}
//Defining the windows media player object in html code
< object type="application/x-oleobject" width="421" height="248" id="VideoPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
< param name="autostart" value="True" / >
< param name="showcontrols" value="false" / >
//in this case wer taking the url from the datagr id link list
< !--< param name="src" value="MediaFiles//YourMovie.wmv" / >-- >
< /object >
//datra grid databinding
protected void gvAvailableVideos_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lbtnVideoFile = ((LinkButton)e.Row.Cells[0].FindControl("lbtnVideoFile"));
if (lbtnVideoFile != null)
{
lbtnVideoFile.Text = gvAvailableVideos.DataKeys[rowno]["VideoFileName"].ToString();
DataView dv = DsMediaFiles.Tables[0].DefaultView;
dv.Sort = "id";
int rowId = dv.Find(gvAvailableVideos.DataKeys[rowno]["Id"]);
string VideoPath=string.Empty;
if(rowId != -1)
{
VideoPath = dv[rowId]["VideoPath"].ToString();
lbtnVideoFile.Attributes.Add("OnClick", "return SetMovie('" + VideoPath + "')");
}
}
rowno += 1;
}
//datagrid handiling html view
< asp:GridView ID="gvAvailableVideos" runat="server" Width="100%" AllowPaging="True" OnRowDataBound="gvAvailableVideos_RowDataBound" AutoGenerateColumns="False" DataKeyNames="Id,VideoFileName" >
< Columns >
< asp:TemplateField HeaderText="VideoFileName" >
< ItemTemplate >
< asp:LinkButton ID="lbtnVideoFile" CommandArgument='< %# Eval("VideoFileName")% >' runat="server" > </asp:LinkButton >
< /ItemTemplate >
< /asp:TemplateField >
< asp:BoundField DataField="AttachmentName" HeaderText="Attachment Name" / >
< /Columns >
< /asp:GridView >
Friday, February 22, 2008
Create a simple Movie player For html site
< object type="video/x-ms-wmv"
data="YourMovie.wmv" width="320" height="260" >
<param name="src" value="YourMovie.wmv" />
<param name="autostart" value="true" />
<param name="controller" value="true" />
</object >
data="YourMovie.wmv" width="320" height="260" >
<param name="src" value="YourMovie.wmv" />
<param name="autostart" value="true" />
<param name="controller" value="true" />
</object >
Thursday, February 21, 2008
Creating mail Class Using C# dotnet (2005VS)
public bool SendEmailUserRegistration(string strEmailFrom, string strEmailTo, string strMailSubject ,string strMailBody,string username,string password)
{
try
{
SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationSettings.AppSettings["SmtpServer"]);
smtp.Host = "127.0.0.1";
smtp.Port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["Port"]);
MailMessage message = new MailMessage(strEmailFrom, strEmailTo);
message.From = new MailAddress(strEmailFrom,"Admin");
message.Subject = System.Configuration.ConfigurationSettings.AppSettings["MessageSubjectUserCreation"].ToString();
message.IsBodyHtml = true;
message.Body = System.Configuration.ConfigurationSettings.AppSettings["MessageBodyUserCreation"].ToString() +"User Name: " + username+ "
" +"Password: "+ password;
//smtp.Send(strEmailFrom, "Name@Company.com", "test subject", strMailBody);
smtp.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}
{
try
{
SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationSettings.AppSettings["SmtpServer"]);
smtp.Host = "127.0.0.1";
smtp.Port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["Port"]);
MailMessage message = new MailMessage(strEmailFrom, strEmailTo);
message.From = new MailAddress(strEmailFrom,"Admin");
message.Subject = System.Configuration.ConfigurationSettings.AppSettings["MessageSubjectUserCreation"].ToString();
message.IsBodyHtml = true;
message.Body = System.Configuration.ConfigurationSettings.AppSettings["MessageBodyUserCreation"].ToString() +"User Name: " + username+ "
" +"Password: "+ password;
//smtp.Send(strEmailFrom, "Name@Company.com", "test subject", strMailBody);
smtp.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}
Wednesday, February 20, 2008
Change the maximum file upload size supported by ASP.NET
Indicates the maximum file upload size supported by ASP.NET. This limit can be used to prevent denial of service attacks caused by users posting large files to the server. The size specified is in kilobytes. The default is 4096 KB (4 MB).
Add this code to webconfig
==========================
system.web
httpRuntime maxRequestLength="2097151" executionTimeout="3600"
system.web
Add this code to webconfig
==========================
system.web
httpRuntime maxRequestLength="2097151" executionTimeout="3600"
system.web
Monday, February 18, 2008
Create a dataset Using Specified colum name and to data table C# code
DataSet dsTemp = new DataSet();
//dsTemp = null;
int recqty = 0;
DataTable dtAddNewItems = new DataTable();
DataColumn[] columns = {
new DataColumn("Product_No"),
new DataColumn("Qty_Received"),
new DataColumn("Certificates"),
new DataColumn("CertificateContentType"),
new DataColumn("TransportDamage"),
new DataColumn("PurrchaseQty"),
new DataColumn("Lot_No"),
new DataColumn("Qty_Returned")
};
dtAddNewItems.Columns.AddRange(columns);
dsTemp.Tables.Add(dtAddNewItems);
//dsTemp = null;
int recqty = 0;
DataTable dtAddNewItems = new DataTable();
DataColumn[] columns = {
new DataColumn("Product_No"),
new DataColumn("Qty_Received"),
new DataColumn("Certificates"),
new DataColumn("CertificateContentType"),
new DataColumn("TransportDamage"),
new DataColumn("PurrchaseQty"),
new DataColumn("Lot_No"),
new DataColumn("Qty_Returned")
};
dtAddNewItems.Columns.AddRange(columns);
dsTemp.Tables.Add(dtAddNewItems);
Find a list Box is Checked (has a list count) using java script
function listBoxisChecked(s,e)
{
var Lstbox=document.getElementById('ctl00_ContentPlaceHolder2_lbxAssignedGroup');
if(Lstbox.options.length == 0)
{
e.IsValid = false;
return;
}
e.IsValid = true;
}
{
var Lstbox=document.getElementById('ctl00_ContentPlaceHolder2_lbxAssignedGroup');
if(Lstbox.options.length == 0)
{
e.IsValid = false;
return;
}
e.IsValid = true;
}
Get Print screen Popup using javascript
html
head
script type="text/javascript">
windows.print();
/script
/head
/html
head
script type="text/javascript">
windows.print();
/script
/head
/html
Friday, February 8, 2008
Random password Creator C# code
public static string CreateRandomPassword(int PasswordLength)
{
string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!@$?";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
{
string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!@$?";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
Subscribe to:
Posts (Atom)