G
Guest
Hi expert,
I have a small web application in C# and ASP.Net and I want to open a file
in notepad when clicked on a linked button. Here is hander code when clicked
on the link button. It can open a process of notepad on the server , but
does not open the file in notepad. What am I doing wrong? can you show me how
to do it please? What I am doing here is : I have datagrid data and when
clicked on linkbutton (logFile), it finds the row identifier and the n
check if any log file exists for that row. If exists, then it should open log
file for that row. When cliked on the link button, it should execute the
ItemClick eventHander.
private void ItemClick(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//if (((LinkButton)e.CommandSource).CommandName == "SelectItem")
//if (((LinkButton)e.CommandSource).CommandName == "GetLogFile")
try
{
//
//get the row index
int intIndex = (int)dgJobname.DataKeys[e.Item.ItemIndex];
string jobID = ((TextBox)e.Item.Cells[0].Controls[0]).Text;
dvJobStep.RowFilter = "job_id = '" + jobID + "'";
foreach( DataRowView drv in dvJobStep)
{
if (drv["output_file_name"].ToString() != null)
outfile = drv["output_file_name"].ToString();
outfile = outfile.Replace(":","$");
}
// Get the UNC file path
correctfile = @"\\" + Session["ServerName"] + @"\" + outfile;
//checking correct file path
lblError.Text = correctfile;
Process proc = new Process();
//ProcessStartInfo oStartInfo = new ProcessStartInfo();
proc.StartInfo.FileName = "notep ad.exe";
proc.StartInfo.Arguments = correctfile;
//notePad.StartInfo.Arguments = outfile;
proc.Start();
//dgJobname.DataBind();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
//dgJobname.DataBind();
//Response.Write(outfile);
}
Thank you so much for your help.
Rabindra
I have a small web application in C# and ASP.Net and I want to open a file
in notepad when clicked on a linked button. Here is hander code when clicked
on the link button. It can open a process of notepad on the server , but
does not open the file in notepad. What am I doing wrong? can you show me how
to do it please? What I am doing here is : I have datagrid data and when
clicked on linkbutton (logFile), it finds the row identifier and the n
check if any log file exists for that row. If exists, then it should open log
file for that row. When cliked on the link button, it should execute the
ItemClick eventHander.
private void ItemClick(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//if (((LinkButton)e.CommandSource).CommandName == "SelectItem")
//if (((LinkButton)e.CommandSource).CommandName == "GetLogFile")
try
{
//
//get the row index
int intIndex = (int)dgJobname.DataKeys[e.Item.ItemIndex];
string jobID = ((TextBox)e.Item.Cells[0].Controls[0]).Text;
dvJobStep.RowFilter = "job_id = '" + jobID + "'";
foreach( DataRowView drv in dvJobStep)
{
if (drv["output_file_name"].ToString() != null)
outfile = drv["output_file_name"].ToString();
outfile = outfile.Replace(":","$");
}
// Get the UNC file path
correctfile = @"\\" + Session["ServerName"] + @"\" + outfile;
//checking correct file path
lblError.Text = correctfile;
Process proc = new Process();
//ProcessStartInfo oStartInfo = new ProcessStartInfo();
proc.StartInfo.FileName = "notep ad.exe";
proc.StartInfo.Arguments = correctfile;
//notePad.StartInfo.Arguments = outfile;
proc.Start();
//dgJobname.DataBind();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
//dgJobname.DataBind();
//Response.Write(outfile);
}
Thank you so much for your help.
Rabindra