//First download xpiinstall.exe and install into your system.
applet code="JavaFile.class" width="100%" codebase="CodePath" height="40" archive="JavaFile.jar">
param value="CodePath" name="url" />
param value="" name="dataurl" />
/applet>*/
ASP.NET MVC, C#, MS SQL Server, EF, MySql Server, Linq, Jquery, Java Script, Interview Questions. If you are looking for updates than kindly subscribe with this blog.
Monday, March 22, 2010
Friday, March 12, 2010
How to create dynamically LinkButton with Literal Control in ASP.NET
Step 1 : First take following control into the .aspx page.
asp:UpdatePanel id="up1" runat="server">
contenttemplate>
asp:Literal ID="lt1" Text="" runat="server">
asp:PlaceHolder ID="ph1" runat="server">
/asp:PlaceHolder>
/contenttemplate>
/asp:UpdatePanel>
Step 2 :
string query = query for fill the dataset;
DataSet ds = new DataSet();
ds = pass the query to retrive data;
int i = 0;
LinkButton lt = new LinkButton();
for (i = 0; i < ds.Tables[0].Rows.Count; i++)
{
lt = new LinkButton();
lt.ID = "link" + i.ToString();
lt.Text = ds.Tables[0].Rows[i].ItemArray[1].ToString();
ph1.Controls.Add(lt);
ph1.Controls.Add(new LiteralControl("
"));
}
asp:UpdatePanel id="up1" runat="server">
contenttemplate>
asp:Literal ID="lt1" Text="" runat="server">
asp:PlaceHolder ID="ph1" runat="server">
/asp:PlaceHolder>
/contenttemplate>
/asp:UpdatePanel>
Step 2 :
string query = query for fill the dataset;
DataSet ds = new DataSet();
ds = pass the query to retrive data;
int i = 0;
LinkButton lt = new LinkButton();
for (i = 0; i < ds.Tables[0].Rows.Count; i++)
{
lt = new LinkButton();
lt.ID = "link" + i.ToString();
lt.Text = ds.Tables[0].Rows[i].ItemArray[1].ToString();
ph1.Controls.Add(lt);
ph1.Controls.Add(new LiteralControl("
"));
}
Thursday, March 11, 2010
How to use Ajax : CollapsiblePanelExtender in ASP.NET
//It is simple method, Other properties will be set which you want
Step 1: Take one panel and all the content you want to collapse put into this panel.
Step 2: Set the Collapsed Property true.
Step 3: ExpandControlID/CollapseControlID : The Controls that will expand or collapse the panel on a click, respectively. If these values are the same, the panel will automatically toggle its state on each click.
Step 4: TargetControlID is PanelID
Step 5: Select Panel and Set the Property SuppressPostBack="True"
Step 1: Take one panel and all the content you want to collapse put into this panel.
Step 2: Set the Collapsed Property true.
Step 3: ExpandControlID/CollapseControlID : The Controls that will expand or collapse the panel on a click, respectively. If these values are the same, the panel will automatically toggle its state on each click.
Step 4: TargetControlID is PanelID
Step 5: Select Panel and Set the Property SuppressPostBack="True"
How to use Ajax : Hovermenu Extender in ASP.NET
// It is a simple method, Other properties set by you which you want
Step 1. Take the control that the extender is targeting.When the mouse cursor is over this control,the hover menu popup will be displayed.
Step 2. Take one panel to display when mouse is over the target control
Step 3. Set the following properties:
TargetControlID = "ID of the panel or control which display when mouse is over the target control"
PopupControlID = "ID of the control that the extender is targeting"
PopupPosition = Left (Default), Right, Top, Bottom, Center.
Step 1. Take the control that the extender is targeting.When the mouse cursor is over this control,the hover menu popup will be displayed.
Step 2. Take one panel to display when mouse is over the target control
Step 3. Set the following properties:
TargetControlID = "ID of the panel or control which display when mouse is over the target control"
PopupControlID = "ID of the control that the extender is targeting"
PopupPosition = Left (Default), Right, Top, Bottom, Center.
Wednesday, March 3, 2010
Web Application : How to upload multiple images at a time
//First add image control into the web form how many you want to upload images at a time
//Add one button
//Write the below code into the button_click event
if (FileUpload1.HasFile)
{
string imagefile = FileUpload1.FileName;
if (CheckFileType(imagefile) == true)
{
Random rndob = new Random();
int db = rndob.Next(1, 100);
filename = System.IO.Path.GetFileNameWithoutExtension(imagefile) + db.ToString() + System.IO.Path.GetExtension(imagefile);
String FilePath = "images/" + filename;
FileUpload1.SaveAs(Server.MapPath(FilePath));
objimg.ImageName = filename;
Image1();
if (Session["imagecount"].ToString() == "1")
{
Img1.ImageUrl = FilePath;
ViewState["img1"] = FilePath;
}
else if (Session["imagecount"].ToString() == "2")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = FilePath;
ViewState["img2"] = FilePath;
}
else if (Session["imagecount"].ToString() == "3")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = ViewState["img2"].ToString();
Img3.ImageUrl = FilePath;
ViewState["img3"] = FilePath;
}
else if (Session["imagecount"].ToString() == "4")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = ViewState["img2"].ToString();
Img3.ImageUrl = ViewState["img3"].ToString();
Img4.ImageUrl = FilePath;
ViewState["img4"] = FilePath;
}
else if (Session["imagecount"].ToString() == "5")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = ViewState["img2"].ToString();
Img3.ImageUrl = ViewState["img3"].ToString();
Img4.ImageUrl = ViewState["img4"].ToString();
Img5.ImageUrl = FilePath;
ViewState["img5"] = FilePath;
}
}
}
//execption handling
else
{
lblErrMsg.Visible = true;
lblErrMsg.Text = "";
lblErrMsg.Text = "please select a file";
}
}
//if file extension belongs to these list then only allowed
public bool CheckFileType(string filename)
{
string ext;
ext = System.IO.Path.GetExtension(filename);
switch (ext.ToLower())
{
case ".gif":
return true;
case ".jpeg":
return true;
case ".jpg":
return true;
case ".bmp":
return true;
case ".png":
return true;
default:
return false;
}
}
//Add one button
//Write the below code into the button_click event
if (FileUpload1.HasFile)
{
string imagefile = FileUpload1.FileName;
if (CheckFileType(imagefile) == true)
{
Random rndob = new Random();
int db = rndob.Next(1, 100);
filename = System.IO.Path.GetFileNameWithoutExtension(imagefile) + db.ToString() + System.IO.Path.GetExtension(imagefile);
String FilePath = "images/" + filename;
FileUpload1.SaveAs(Server.MapPath(FilePath));
objimg.ImageName = filename;
Image1();
if (Session["imagecount"].ToString() == "1")
{
Img1.ImageUrl = FilePath;
ViewState["img1"] = FilePath;
}
else if (Session["imagecount"].ToString() == "2")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = FilePath;
ViewState["img2"] = FilePath;
}
else if (Session["imagecount"].ToString() == "3")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = ViewState["img2"].ToString();
Img3.ImageUrl = FilePath;
ViewState["img3"] = FilePath;
}
else if (Session["imagecount"].ToString() == "4")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = ViewState["img2"].ToString();
Img3.ImageUrl = ViewState["img3"].ToString();
Img4.ImageUrl = FilePath;
ViewState["img4"] = FilePath;
}
else if (Session["imagecount"].ToString() == "5")
{
Img1.ImageUrl = ViewState["img1"].ToString();
Img2.ImageUrl = ViewState["img2"].ToString();
Img3.ImageUrl = ViewState["img3"].ToString();
Img4.ImageUrl = ViewState["img4"].ToString();
Img5.ImageUrl = FilePath;
ViewState["img5"] = FilePath;
}
}
}
//execption handling
else
{
lblErrMsg.Visible = true;
lblErrMsg.Text = "";
lblErrMsg.Text = "please select a file";
}
}
//if file extension belongs to these list then only allowed
public bool CheckFileType(string filename)
{
string ext;
ext = System.IO.Path.GetExtension(filename);
switch (ext.ToLower())
{
case ".gif":
return true;
case ".jpeg":
return true;
case ".jpg":
return true;
case ".bmp":
return true;
case ".png":
return true;
default:
return false;
}
}
How to submit a form on pressing enter key
function clickButton(e, buttonid)
{
var bt = document.getElementById(buttonid);
if (typeof bt == 'object'){
if(navigator.appName.indexOf("Netscape")>(-1)){
if (e.keyCode == 13){
bt.click();
return false;
}
}
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
{
if (event.keyCode == 13){
bt.click();
return false;
}
}
}
}
//Call this function on last text box of a form with onKeyPress="clickButton(this)"
{
var bt = document.getElementById(buttonid);
if (typeof bt == 'object'){
if(navigator.appName.indexOf("Netscape")>(-1)){
if (e.keyCode == 13){
bt.click();
return false;
}
}
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
{
if (event.keyCode == 13){
bt.click();
return false;
}
}
}
}
//Call this function on last text box of a form with onKeyPress="clickButton(this)"
Subscribe to:
Posts (Atom)