|
Hi,
I have a dotnet application in which i have to take text documents from a specified folder in a selected date criteria. i'm using date picker for this. Suppose if i have to fetch the files form some 30/11/2006 to 31/11/2006. For that there will be a folder created in the client name inside the folder there will be folders created in the name 3011 and 3111 respectively with the corresponding dates which has been coded already in the same project. my question is i have to fetch those records if i select a from data and todate and click submit it has to fetch the records from the folder and has to be displayed ascendingly according to the date specified. i've just started working on it and i have been struggling in the middle. can anybody pls help me with a proper solution. i'm struggling with this.. here is the code which i have completed.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Text;
using My_Sql;
namespace hsusa
{
///
/// Summary description for NewClientRecords.
///
public class NewClientRecords : System.Web.UI.Page
{
protected eWorld.UI.CalendarPopup CalTxtFromDate;
protected System.Web.UI.WebControls.Label lblDictTo;
protected eWorld.UI.CalendarPopup CalTxtToDate;
protected System.Web.UI.WebControls.Button btnSearch;
protected System.Web.UI.WebControls.DataGrid MultiDocumentGrid;
protected System.Web.UI.WebControls.Label lblDictFrom;
public string lbl;
protected BunnyBear.msgBox MsgBox1;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Label Label3;
protected OdbcConnection UserCon;
protected OdbcDataAdapter UserAdap;
protected OdbcCommand UserCmd;
DateTime FromDate;
protected System.Web.UI.WebControls.Button Button1;
DateTime ToDate;
string Accname;
string FolderName;
string strUserAcc;
int EDIT;
int VIEW;
int PRINT;
private void Page_Load(object sender, System.EventArgs e)
{
// string z = Session["UserName"].ToString();
//
// //string z = "hsusa" ;
////
// strUserAcc = GetUserAcc(z).ToString();
////
// GetUserPermissions(z);
}
private void Button1_Click(object sender, System.EventArgs e)
{
//string z = "hsusa" ;
//strUserAcc = GetUserAcc(z).ToString();
//GetUserPermissions(z);
if(CalTxtFromDate.SelectedDate>CalTxtToDate.SelectedDate)
{
MsgBox1.alert("From date cannot be greater than to date");
}
else if(CalTxtFromDate.SelectedDate > DateTime.Now.Date)
{
MsgBox1.alert("From-Date cannot be greater than Current-date");
}
else if(CalTxtToDate.SelectedDate > DateTime.Now.Date)
{
MsgBox1.alert("To-Date cannot be greater than Current-date");
}
else
{
// FromDate = CalTxtFromDate.SelectedDate.AddDays(1);
// ToDate = CalTxtToDate.SelectedDate.AddDays(1);
// Get folders in between these dates
FromDate = CalTxtFromDate.SelectedDate;
ToDate = CalTxtToDate.SelectedDate;
string FolderDay = FromDate.Day.ToString();
string FolderMonth = FromDate.Month.ToString();
string FolderDay1 = ToDate.Day.ToString();
string FolderMonth1 = ToDate.Month.ToString();
if(int.Parse(FolderDay) <=9&&int.Parse(FolderMonth) <=9)
{
FolderName = "0" + FolderMonth + "0" + FolderDay.Trim();
}
else if(int.Parse(FolderDay) <=9)
{
FolderName = FolderMonth + "0" + FolderDay.Trim();
}
else if(int.Parse(FolderMonth) <=9)
{
FolderName = "0" + FolderMonth + FolderDay.Trim();
}
else
{
FolderName = FolderMonth + FolderDay.Trim();
}
if(int.Parse(FolderDay1) <=9&&int.Parse(FolderMonth1) <=9)
{
FolderName = "0" + FolderMonth1 + "0" + FolderDay1.Trim();
}
else if(int.Parse(FolderDay1) <=9)
{
FolderName = FolderMonth1 + "0" + FolderDay1.Trim();
}
else if(int.Parse(FolderMonth1) <=9)
{
FolderName = "0" + FolderMonth1 + FolderDay1.Trim();
}
else
{
FolderName = FolderMonth1 + FolderDay1.Trim();
}
try
{
string file;
string[] files;
string filepath;
int last;
//string Accname = Request.Params["Accname"].ToString();
Accname = "SMITH" ;
//Accname = strUserAcc;
DataTable dataTable=new DataTable();
dataTable.Columns.Add(new DataColumn("TextFileName"));
dataTable.Columns.Add(new DataColumn("Date"));
//dataTable.Columns.Add(new DataColumn("DocumentFullPath"));
DataRow dataRow;
filepath = "d:\\Text\\" + Accname + "\\" + FolderName;
files = Directory.GetFiles(@filepath);
for(int i=0;i<files.length;i++)
{
=""
="" datarow="dataTable.NewRow();" file="Path.GetFullPath(files[i]);
" last="file.LastIndexOf("\\");" int="" fileindex="last+1" ;
="" string="" filename="file.Substring" (fileindex);
="" datarow["documentfullpath"]="file;
" datarow["textfilename"]="Filename" datarow["date"]="FolderName;
" datatable.rows.add(datarow);="" }
="" dataset="" dataset();
="" dataset.tables.add(datatable);
="" multidocumentgrid.datasource="dataSet;
" multidocumentgrid.databind();
="" }
="" catch(exception="" ex)
="" label3.text="File Not Found." }=""
="" private="" void="" multidocumentgrid_itemdatabound(object="" sender,="" datagriditemeventargs="" e)
="" {
="" textfilename="e.Item.Cells[2].Text.Trim();
" if="" (edit="=" 0)="" e.item.cells[0].controls.add(new="" literalcontrol("<a="" href="#" onclick="\"window.open('DisplayNew.aspx?PrintDoc=N&FileName="" +="" "&acname=" + Accname + " &foldername=" + FolderName + " ','text','menubar="false')\"">" + TextFileName + ""));
e.Item.Cells[0].Controls.Add(new LiteralControl(" "));
}
else
{
e.Item.Cells[0].Controls.Add(new LiteralControl("" + TextFileName + ""));
// e.Item.Cells[0].Controls.Add(new LiteralControl(" "));
}
}
}
}
Thanks and Regards
Vijay.
|
|
|
|
|
I couldn't really follow your explanation because of the lack of punctuation, it's really hard to read something when you can't tell where one sentence ends and the next begins. You posted your code without using the pre tag, so it lost all indentation, so I didn't even try to read it. You should also post only the relevant code, not your entire project.
It would also help if you specified a little more clearly what it is your are "struggling" with in the "middle".
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: it lost all indentation, so I didn't even try to read it
|
|
|
|
|
I have a Datagrid. I am taking a selected row to the datatable(session).My problem is inside the datagrid in one cell there is a textbox. the value from the textbox is not binding to datatable. Can anybody help please.
|
|
|
|
|
Hi,
Can you post your code how do u store rows in the session?
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
DataTable dt = new DataTable();
dt.Columns.Add("feild1", System.Type.GetType("System.Int32"));
dt.Columns.Add("feild2", System.Type.GetType("System.String"));
dt.Columns.Add("feild3", System.Type.GetType("System.String"));
dt.Columns.Add("feild4", System.Type.GetType("System.String"));
dt.AcceptChanges();
DataRow l_rowDetails = dt.NewRow();
l_rowDetails["feild1"] = (GridView1.SelectedRow.Cells[1].Text);
l_rowDetails["feild2"] = GridView1.SelectedRow.Cells[2].Text;
l_rowDetails["feild3"] = GridView1.SelectedRow.Cells[3].Text;
l_rowDetails["feild4"] = GridView1.SelectedRow.Cells[4].Text;
dt.Rows.Add(l_rowDetails);
dt.AcceptChanges();
Session["datatable"] = dt;
|
|
|
|
|
Hi,
Here u r pushing text of the cell.
If u want to take value from the textbox then you should find textbox in the cell and then take its text property and insert it in to the table.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
sasim@choice-solutions.com
sasim
|
|
|
|
|
HI,
You can not create a dynamic event handler but you can assign an existing one to an event of dynamic control.
1. Create a handler which u want to call when event happens.
2. Assign that to the event of your dynamic control.
protected void bttn_Click(object sender, EventArgs e)
{
//Code;
}
Create dynamic button and assign above event handler to its click event.
button bttn = new Button();
bttn.Click += new EventHandler( bttn_Click );
I hope this will help u.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
How do I implement or write javascript in source -> means in aspx. File
If I write as java script code I can’t access the normal button like label etc.
I want to execute function when form is loaded
How to do it?
To test I have written code like this
1.
function getlabel()
{ alert("formload");
alert(Text1.value)}
2.
void getlabel()
{
Response.Write(Label2.Text);
Response.Write(TextBox1.Text);
}
…..
neigther of this method is working
.
vijaya
|
|
|
|
|
Research the Page.RegisterClientScriptBlock method (ASP.NET 1.1) or ClientScript.RegisterClientScriptBlock (later versions - though the former will still work as well)
Fred
|
|
|
|
|
That seems like overkill for inline script wouldn't you say? Think he's asking how to add js directly into the aspx, rather than using the codebehind to register it...
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
Yes, ok - I think you're right. Oh well - two lessons for the price of one - a bargain!
Fred
|
|
|
|
|
lol!
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
Label2 and TextBox1 are the names of the server-side controls. To get access to these controls on the client-side you need to use document.GetElementById("Label2") and document.getElementById("TextBox1")
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: Label2 and TextBox1 are the names of the server-side controls. To get access to these controls on the client-side you need to use document.GetElementById("Label2") and document.getElementById("TextBox1")
And then of course, use .value rather than .text to get the data out
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
I left that detail out on purpose. Got to have them think of something, can't just give it all away.;P
only two letters away from being an asset
|
|
|
|
|
ahhhhhhh - I have much to learn sensei!
TBH, was just trying to head off the next message which would probably gone something like....
"My page doesn't work - send me the codes for getting the text! It's URGENT!"
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
kvijayajyothy wrote: alert(Text1.value)}
This doesn't work for two reasons:
1 - Text1 exists on the server, not the client
2 - If Text1 is a server side control, the framework generates it's own Id for the client.
This will work:
function getlabel()
{
var controlId = '<%=Text1.ClientID%>';
var control = document.getElementByID(controlID);
if (control)
{
alert(control.value);
}
<div class="ForumSig">Christian Graus - Microsoft MVP - C++
<a href='http://blog.metalmusings.com/'>Metal Musings</a> - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )</div>
|
|
|
|
|
Hi all
I am working on asp.net application where i need to upload a file. code what i wrote is
Private Sub CmdUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdUpload.Click
If File1.PostedFile Is Nothing Then
Me.lblResult.Text = "No File Selected to Upload."
Exit Sub
End If
'Retrieve file information and upload to server.
Dim strName As String
strName = System.IO.Path.GetFileName(File1.PostedFile.FileName)
Try
File1.PostedFile.SaveAs(Server.MapPath("Resumes/" & strName))
Me.lblResult.Text = """" + strName + """ was uploaded successfully."
Catch ex As Exception
Me.lblResult.Text = "An Error Occured While Uploading File."
End Try
End Sub
Every thing is fine but its showing a error after the upload button is clicked " No access to write into the server " right now i am using my local system as server and i have clicked on all access permission "Write" . but getting the same error.
Pl help
Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
Try adding a line like this:
<identity impersonate="true" username="xxx" password="yyy" />
inside the system.web block of your web.config file, replacing xxx/yyy with your admin login to your computer. <u>Make sure you take this line out when uploading to the deployment server!</u> (And get the administrators of that to enable the appropriate write permissions for you there...)
Works for me - like you I could not, for the life of me, grant asp.net write permissions otherwise...
cheers
Fred
|
|
|
|
|
I wang to ask a question about GridView.
I have checkbox control and radiobuttonlist control in GridView.
The radiobuttonlist's enabled=false;
When the page load,when the checkbox is checked of the gridview's row,
the control radiobuttonlist's enabled=true;
Now, I want to implement it by javascript,How can i do ?
I had search the awnser about it ,but no .
I need help.
thank you .
Bennyzhang
Best Wishes!
|
|
|
|
|
Hi,
My asp.net 1.1 website security system depend on hashing passwords.So it is impossible to recover the password.I think when the user forgot his password the web application should generate a password for him automatically and send it to his email so he can log again using his new password.Could any one tell me how could I make the web application generate the password automatically?Is it safe to send it by email to the user?
I am too late but i will never give up
|
|
|
|
|
Yes, email is fine, it's certainly your most secure option. How you generate it is up to you, you could send part of a GUID, or have a table full of words and pull three out at random, or whatever you like.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: you could send part of a GUID
Do you mean that I should add a new column of type GUID in the users table...I think it is a great idea because the passwords I sent to them will differ from each other.
Thank you for these great ideas.
I am too late but i will never give up
|
|
|
|