<script language="javascript" type="text/javascript">
/*To check file extensions */
function checkFileExtension( s,e ){
parafilevalue =document.getElementById("FileUpload1").value
var file = parafilevalue.split('.');
var validType = false;
if( file.length < 2 )
{
return false;
}
var fileext = file[1].toLowerCase();
if( fileext == 'doc' || fileext == 'pdf'|| fileext == 'xls' || fileext == 'ppt'|| fileext == 'txt' )
{
validType = true;
}
if(validType==false)
{
alert("Please enter specified document type");
var who= document.getElementsByName('FileUpload1')[0];
var who2= who.cloneNode(false);
who2.onchange = who.onchange;
who.parentNode.replaceChild(who2,who);
}
return validType;
}
< /script >
Friday, May 2, 2008
Tuesday, April 8, 2008
Add navigate url for the Datagrid using row data bound event (Template colum Used in hear)- Sanjeewa Sapumana
protected void gvCourseList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lnkAssign = (LinkButton)e.Row.Cells[2].Controls[1];
if (lnkAssign != null)
{
lnkAssign.PostBackUrl = "AssignCourse.aspx?PaperId=" + gvCourseList.DataKeys[e.Row.RowIndex].Values["PaperId"].ToString();
}
LinkButton lnkAssignUser = (LinkButton)e.Row.Cells[3].Controls[1];
if (lnkAssignUser != null)
{
lnkAssignUser.PostBackUrl = "AssignUsers.aspx?PaperId=" + gvCourseList.DataKeys[e.Row.RowIndex].Values["PaperId"].ToString();
}
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lnkAssign = (LinkButton)e.Row.Cells[2].Controls[1];
if (lnkAssign != null)
{
lnkAssign.PostBackUrl = "AssignCourse.aspx?PaperId=" + gvCourseList.DataKeys[e.Row.RowIndex].Values["PaperId"].ToString();
}
LinkButton lnkAssignUser = (LinkButton)e.Row.Cells[3].Controls[1];
if (lnkAssignUser != null)
{
lnkAssignUser.PostBackUrl = "AssignUsers.aspx?PaperId=" + gvCourseList.DataKeys[e.Row.RowIndex].Values["PaperId"].ToString();
}
}
}
Friday, March 7, 2008
How to Enable AjaxPro to your Websiteand call ajax Method Sanjeewa sapumana
(1)//add ajax pro dll
AjaxPro.2.dll
(2)//add this codes to page load here type of=Class name
AjaxPro.Utility.RegisterTypeForAjax(typeof(PlayMedia));
(3)//Add this code top of the method
[AjaxPro.AjaxMethod()]
(4)//your method here
public void UpdateTime(string strVideoViewTimeInMinute)
{
}
(5)//Add this codes for the Web config
(6)//call your method acording event
//IN HTML call the method as this
PlayMedia.UpdateTime(videoviewTime.toString());
AjaxPro.2.dll
(2)//add this codes to page load here type of=Class name
AjaxPro.Utility.RegisterTypeForAjax(typeof(PlayMedia));
(3)//Add this code top of the method
[AjaxPro.AjaxMethod()]
(4)//your method here
public void UpdateTime(string strVideoViewTimeInMinute)
{
}
(5)//Add this codes for the Web config
(6)//call your method acording event
//IN HTML call the method as this
PlayMedia.UpdateTime(videoviewTime.toString());
Thursday, March 6, 2008
javaScript Call function in every 1 sec(or any time period) Sanjeewa sapumana
//javascript
//in milisecond
var intervaltime=1000;
//Call function in every 1000 milisecond (1 sec)
state=setInterval("ProgressBarUpdate()",intervaltime);
//Finish time out
clearTimeout ( timeoutId );
//in milisecond
var intervaltime=1000;
//Call function in every 1000 milisecond (1 sec)
state=setInterval("ProgressBarUpdate()",intervaltime);
//Finish time out
clearTimeout ( timeoutId );
Friday, February 29, 2008
Creating a folder in the server using asp.net -sanjeewa sapumana
//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;
}
}
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;
}
}
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 >
Subscribe to:
Posts (Atom)