15,917,062 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by v surya dev (Top 36 by date)
v surya dev
23-Jul-13 2:45am
View
Microsoft.Office.Interop.Outlook.MAPIFolder rootFolder = Application.Session.DefaultStore.GetDefaultFolder();
I am getting this error from this line of code 'Session'.....
v surya dev
23-Jul-13 2:44am
View
Deleted
Microsoft.Office.Interop.Outlook.MAPIFolder rootFolder = Application.Session.DefaultStore.GetDefaultFolder();
v surya dev
23-Jul-13 1:28am
View
While i build the application, it throws this Error:
'System.Web.HttpApplicationState' does not contain a definition for 'Session' and no extension method 'Session' accepting a first argument of type 'System.Web.HttpApplicationState' could be found (are you missing a using directive or an assembly reference?)
This is only My issue....
v surya dev
29-Apr-13 2:55am
View
can anyone tell me how to give permission for that folder.... plzzzzzzzzzz
v surya dev
29-Apr-13 2:40am
View
my default running mode is administrator only...
v surya dev
29-Apr-13 2:35am
View
i tried that... but windows xp not showing that security tab.... please help me how to give permission for that folder...
v surya dev
29-Apr-13 1:26am
View
My Code was:
protected void lnkDownload_Click(object sender, EventArgs e)
{
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
int ImageId = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
string name, type;
using (SqlConnection con = new SqlConnection(strCon))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select ImageName, FileName, AddedOn from ImageInfo where ImageId=@ImageId";
cmd.Parameters.AddWithValue("@ImageId", ImageId);
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
// Response.ContentType = dr["AddedOn "].ToString();
// Response.AddHeader("Content-Disposition", "attachment;filename=\"" + dr["ImageName"] + "\"");
System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath("Upload"));
Response.Clear();
Response.ContentType = "application//octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.TransmitFile(Server.MapPath(fi.Name));
Response.End();
}
}
}
}
i uploads the images successfully but... when i tried to download the file it shows is error in c#....
i used varbinary(max) datatype in backend....
v surya dev
29-Apr-13 1:06am
View
thank you... thank you so much....
v surya dev
29-Apr-13 1:06am
View
thank you... thank you so much... its running now....
v surya dev
28-Apr-13 11:23am
View
ya i cleared this... but i have another problem.....
the problem is:
i am using varbinary(MAX) data type... last time i used the same code for the same data type... but now it shows this error...
can you help me...!!!!
Server Error in '/WebSite5' Application.
Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Source Error:
Line 164: // Response.ContentType = dr["AddedOn "].ToString();
Line 165: Response.AddHeader("Content-Disposition", "attachment;filename=\"" + dr["ImageName"] + "\"");
Line 166: Response.BinaryWrite((byte[])dr["FileName"]);
Line 167: Response.End();
Line 168: }
Source File: c:\Users\SURYA-BOSS\Documents\Visual Studio 2010\WebSites\WebSite5\Default.aspx.cs Line: 166
Stack Trace:
[InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.]
_Default.lnkDownload_Click(Object sender, EventArgs e) in c:\Users\SURYA-BOSS\Documents\Visual Studio 2010\WebSites\WebSite5\Default.aspx.cs:166
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +141
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +150
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +38
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +37
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +289
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4225
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
v surya dev
28-Apr-13 10:49am
View
My .CS Code .....
protected void lnkDownload_Click(object sender, EventArgs e)
{
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
int ImageId = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
string name, type;
using (SqlConnection con = new SqlConnection(strCon))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select ImageName, FileName, AddedOn from ImageInfo where ImageId=@ImageId";
cmd.Parameters.AddWithValue("@ImageId", ImageId);
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.ContentType = dr["FileType"].ToString();
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + dr["ImageName"] + "\"");
Response.BinaryWrite((byte[])dr["FileName"]);
Response.End();
}
}
}
}
aspx.code is:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<columns>
<asp:BoundField DataField="ImageId" HeaderText="ImageId" />
<asp:BoundField DataField="ImageName" HeaderText="ImageName" />
<asp:BoundField DataField="AddedOn" HeaderText="AddedOn" />
<asp:TemplateField HeaderText="FilePath">
<itemtemplate>
<asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="lnkDownload_Click">
v surya dev
26-Apr-13 3:21am
View
this is my c# code.....
MenuMapping css1 = new MenuMapping();
protected void Page_Load(object sender, EventArgs e)
{
string ssr = this.Session["RoleName"].ToString();
Session["urlpath"] = Path.GetFileName(Request.Url.AbsolutePath);
// GetPermission();
GetPermission();
if (!this.IsPostBack)
{
grdViewCommonMas.SelectedIndex = 0;
}
}
protected void GetPermission()
{
DataTable dt = new DataTable();
dt.Clear();
dt = css1.Permission((Session["RoleName"].ToString()), "~/" + Session["urlpath"].ToString());
if (dt.Rows.Count != 0)
{
if (Convert.ToInt32(dt.Rows[0]["Read_P"])==1)
{
// ((LinkButton)this.frmViewCommonMas.FindControl("EditButton")).Visible = false;
//((LinkButton)this.frmViewCommonMas.FindControl("DeleteButton")).Visible = false;
//(LinkButton)this.frmViewCommonMas.FindControl("NewButton")).Visible = false;
//((LinkButton)this.frmViewCommonMas.FindControl("InsertButton")).Visible = false;
//((LinkButton)this.frmViewCommonMas.FindControl("UpdateButton")).Visible = false;
// ((LinkButton)this.frmViewCommonMas.FindControl("CancelButton")).Visible = false;
//((LinkButton)this.grdViewCommonMas.FindControl("Button")).Visible = true;
}
if (Convert.ToInt32(dt.Rows[0]["Write_P"]) == 1)
{
// ((LinkButton)this.frmViewCommonMas.FindControl("EditButton")).Visible = false;
// ((LinkButton)this.frmViewCommonMas.FindControl("DeleteButton")).Visible = false;
((LinkButton)this.frmViewCommonMas.FindControl("NewButton")).Visible = true;
((LinkButton)this.frmViewCommonMas.FindControl("InsertButton")).Visible = true;
//((LinkButton)this.frmViewCommonMas.FindControl("CancelButton")).Visible = true;
//((LinkButton)this.grdViewCommonMas.FindControl("SelectButton")).Visible = true;
}
if (Convert.ToInt32(dt.Rows[0]["Update_P"]) == 1)
{
//((LinkButton)this.frmViewCommonMas.FindControl("EditButton")).Visible = false;
//((LinkButton)this.frmViewCommonMas.FindControl("DeleteButton")).Visible = false;
// ((LinkButton)this.frmViewCommonMas.FindControl("NewButton")).Visible = true;
}
if (Convert.ToInt32(dt.Rows[0]["Delete_P"]) == 1)
{
// ((LinkButton)this.frmViewCommonMas.FindControl("EditButton")).Visible = false;
// ((LinkButton)this.frmViewCommonMas.FindControl("DeleteButton")).Visible = false;
//((LinkButton)this.frmViewCommonMas.FindControl("NewButton")).Visible = true;
}
}
}
protected void frmViewCommonMas_ItemInserted(Object sender, FormViewInsertedEventArgs e)
{
if (e.Exception == null)
{
grdViewCommonMas.DataBind();
}
}
protected void frmViewCommonMas_ItemUpdated(Object sender, FormViewUpdatedEventArgs e)
{
if (e.Exception == null)
{
grdViewCommonMas.DataBind();
}
}
protected void frmViewCommonMas_ItemDeleted(Object sender, FormViewDeletedEventArgs e)
{
if (e.Exception == null)
{
grdViewCommonMas.DataBind();
}
}
//protected void grdViewCommonMas_SelectedIndexChanged(object sender,GridViewSelectEventArgs e)
//{
// GetPermission();
//}
//protected void grdViewCommonMas_IndexChanging(object sender, EventArgs e)
//{
// GetPermission();
//}
protected void grdViewCommonMas_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
// GetPermission();
}
}
//protected v
v surya dev
24-Apr-13 8:11am
View
pls anyne help me..?
v surya dev
11-Apr-13 11:55am
View
thank u i cleard that error... but now i want to upload my webform using dynamic created datalist menus. can anyone send the code pls...
v surya dev
11-Apr-13 11:29am
View
ya i correctly added that path..
but this error comes again and again...
v surya dev
11-Apr-13 11:15am
View
can anyone help me how to detect this error..?
v surya dev
11-Apr-13 4:07am
View
i tried to add menus and submenus at runtime.... this is what i tried...
v surya dev
11-Apr-13 4:04am
View
anyway thank u boss...
v surya dev
11-Apr-13 3:55am
View
can any one help me..?
v surya dev
11-Apr-13 3:54am
View
s sir, but i am new to session creation, please help me how to clear this..?
this is my code...
my web form code....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class menu_CreateMenu : System.Web.UI.Page
{
public string connection = ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ToString();
string choice = "0";
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=aspnetdb;User ID=sa;Password=voyage");
if (!IsPostBack)
{
FillddlMainMenu();
choice = Session["Choice"].ToString();
if (choice == "Main")
{
pnlMainMenu.Visible = true;
}
else if (choice == "Sub")
{
pnlSubMenu.Visible = true;
}
}
else
{
}
}
protected void btnMainmenu_Click(object sender, EventArgs e)
{
int active;
if (chkMActive.Checked)
{
active = 1;
}
else
{
active = 0;
}
SqlConnection conn = new SqlConnection(connection);
string sql = "INSERT INTO MainMenu(MainMenu, MLocation, MenuOrder, IsActive)VALUES('" + txtMainmenu.Text + "','" + txtMLocation.Text + "'," + Convert.ToInt16(ddlMOrder.SelectedItem.Value) + "," + active + ")";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
conn.Close();
FillddlMainMenu();
Response.Redirect("SuccessMsg.aspx");
}
public void FillddlMainMenu()
{
SqlConnection conn = new SqlConnection(connection);
DataSet DS = new DataSet();
SqlDataAdapter dataadapter = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand("Select MainMenuId,MainMenu from MainMenu", conn);
//cmd.CommandType = CommandType.Text;
dataadapter.SelectCommand = cmd;
dataadapter.Fill(DS);
ddlMainMenu.DataSource = DS;
ddlMainMenu.DataBind();
}
protected void btnSubmenu_Click(object sender, EventArgs e)
{
int active;
if (chkSActive.Checked)
{
active = 1;
}
else
{
active = 0;
}
SqlConnection conn = new SqlConnection(connection);
string sql = "INSERT INTO SubMenu(SubMenu, SubMenuLocation, MenuOrder,ParentId, IsActive)VALUES('" + txtSubmenu.Text + "','" + txtSubMenuLocation.Text + "'," + Convert.ToInt16(ddlSOrder.SelectedItem.Value) + "," + Convert.ToInt16(ddlMainMenu.SelectedItem.Value) + "," + active + ")";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("SuccessMsg.aspx");
}
}
master page code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class menu_MasterPage : System.Web.UI.MasterPage
{
static DataSet static_dataset = new DataSet();
DataTable dt = new DataTable();
public string connection = ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
//if (!IsPostBack)
//{
static_dataset = ds();
dt = static_dataset.Tables[0].Copy();
dt.Clear();
v surya dev
18-Mar-12 4:39am
View
which code i have to provide...? if you have any code... please give to me...
v surya dev
7-Mar-12 4:40am
View
My generic code is:
<%@ WebHandler Language="C#" Class="ImageHandler" %>
using System;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
public class ImageHandler : IHttpHandler
{
string strcon = ConfigurationManager.ConnectionStrings["PayrollConnectionString"].ToString();
public void ProcessRequest (HttpContext context)
{
string imageid = context.Request.QueryString["ImID"];
SqlConnection connection = new SqlConnection(strcon);
connection.Open();
SqlCommand command = new SqlCommand("select Image from Image where ImageID=" + imageid, connection);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
context.Response.BinaryWrite((Byte[])dr[0]);
connection.Close();
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
v surya dev
7-Mar-12 4:36am
View
My aspx Code.....
<%@ Page Title="" Language="C#" MasterPageFile="~/Settings/SettingsPage.master" AutoEventWireup="true" CodeFile="EmployeePhotoMaster.aspx.cs" Inherits="Settings_EmployeePhotoMaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="RightColumn" Runat="Server">
<style type="text/css">
.Gridview
{
font-family:Verdana;
font-size:10pt;
font-weight:normal;
color:black;
width:500px;
}
</style>
<div>
<table>
<tr>
<td>
Image Name:
</td>
<td>
<asp:TextBox ID="txtImageName" runat="server">
</td>
</tr>
<tr>
<td>
Upload Image:
</td>
<td>
<asp:FileUpload ID="fileuploadImage" runat="server" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
</td>
</tr>
</table>
</div>
<div>
<asp:GridView ID="gvImages" CssClass="Gridview" runat="server" AutoGenerateColumns="False"
HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="white"
ViewStateMode="Enabled">
<columns><asp:BoundField HeaderText = "Image Name" DataField="imagename" />
<asp:TemplateField HeaderText="Image">
<itemtemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "ImageHandler.ashx?ImID="+ Eval("ImageID") %>' Height="150px" Width="150px"/>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PayrollConnectionString %>"
SelectCommand="SELECT * FROM [image]">
</div>
My .cs Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class Settings_EmployeePhotoMaster : System.Web.UI.Page
{
string strcon = ConfigurationManager.ConnectionStrings["PayrollConnectionString"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
protected void btnUpload_Click(object sender, EventArgs e)
{
//Condition to check if the file uploaded or not
if (fileuploadImage.HasFile)
{
//getting length of uploaded file
int length = fileuploadImage.PostedFile.ContentLength;
//create a byte array to store the binary image data
byte[] imgbyte = new byte[length];
//store the currently selected file in memeory
HttpPostedFile img = fileuploadImage.PostedFile;
//set the binary data
img.InputStream.Read(imgbyte, 0, length);
string imagename = txtImageName.Text;
//use the web.config to store the connection string
SqlConnection connection = new SqlConnection(strcon);
connection.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO Image (ImageName,Image) VALUES (@imagename,@imagedata)", connection);
cmd.Parameters.Add("@imagename", SqlDbType.VarChar, 50).Value = imagename;
cmd.Parameters.Add("@imagedata", SqlDbType.Image).Value = imgbyte;
int count = cmd.ExecuteNonQuery();
connection.Close();
if (count == 1)
{
BindGridData();
txtImageName.Text = string.Empty;
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + imagename + " image inserted successfully')", true);
}
}
}
///
/// function is used to bind gridview
///
private void BindGridData()
{
SqlConnection connection = new SqlConnection(strcon);
SqlCommand command = new SqlCommand("SELECT imagename,ImageID from [Image]", connection);
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
gvImages.Attributes.Add("bordercolor", "black");
}
}
my generic handler code:
<%@ WebHandler Language="C#" Class="ImageHandler" %>
using System;
using System.Web;
using System.Configuration;
usi
v surya dev
7-Mar-12 4:06am
View
hi... sorry for the disturbance... i tried this code again it successfully stored into the sql server table... but the image didn't displayed into the image control.... can you help me...? what i did wrongly...? please....
v surya dev
6-Mar-12 4:06am
View
really great pa... very very thanks to you... now it's working... thanks a lot....
v surya dev
6-Mar-12 3:50am
View
plz help me....
v surya dev
6-Mar-12 3:47am
View
ya... i did... but... now also i am getting the same error....?
v surya dev
3-Mar-12 5:13am
View
once i import the excel employee OT details for this month.. next month i need not it... so i want to refresh the table all data...plz send me any sample code for that?
v surya dev
27-Feb-12 13:46pm
View
ya... i have that line of code... but i want detailed code.... pls help me...
v surya dev
17-Feb-12 9:18am
View
it will through error todayDate.Text... it does not accept the .Text....
v surya dev
14-Feb-12 5:28am
View
i set this but in my application tool box i didn't find the crystal report viewer ? how can i add?
v surya dev
14-Feb-12 5:21am
View
plz anyone tell how to set?
v surya dev
9-Feb-12 10:47am
View
ya some one expect this... this is my college final year project... i just committed with one company...
v surya dev
9-Feb-12 10:30am
View
thank u..
v surya dev
9-Feb-12 10:05am
View
ya... this is the first time to do in C# and sql server... i am the leaner of c# and sql... plz suggest to me....
v surya dev
9-Feb-12 9:45am
View
thanks for your info...
Show More