|
Dear sir,
basically i want to pass a complete local file path in a method which can be post a file in different server(means i want to upload a file on multiple server at a time, thats why i used ftp class in asp.net to upload the file, it is working Fine in Internet Explorer but not work with Mozila).
My Code Function is
public void uploadFileUsingFTP(string CompleteFTPPath, string CompleteLocalPath, string UName, string PWD)
{
//Create a FTP Request Object and Specfiy a Complete Path
FtpWebRequest reqObj = (FtpWebRequest)WebRequest.Create(CompleteFTPPath);
//Call A FileUpload Method of FTP Request Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
//If you want to access Resourse Protected You need to give User Name and PWD
reqObj.Credentials = new NetworkCredential(UName, PWD);
//FileStream object read file from Local Drive
FileStream streamObj = File.OpenRead(CompleteLocalPath);
//Store File in Buffer
byte[] buffer = new byte[streamObj.Length + 1];
//Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length);
//Close FileStream Object Set its Value to nothing
streamObj.Close();
//Upload File to ftp://localHost/ set its object to nothing
reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);
}ashutosh kumar jha
|
|
|
|
|
Hey Asutosh,
I think you are missing out the point. From the web site, you can send files only through httpstreams. To invoke FTP from the client side you need client side sandbox apps etc which are capable of invoking Ftp requests to the server.
Other than that, if you are willing to invoke FTP request to the FTP server from the hosting application, you need to upload the files through HTTP, and then you need to send the file to the FTP location, invoking a new FTP session to that server.
Actually one thing you must remember, Server cant request a client to get a file. Even though you send the client full file path to the ftp server, if the client remains idle, server cannot get the file.
I hope this is clear now.
|
|
|
|
|
Hi,
I have a custom paged grid user control on my page. the problem is everytime the last page number is clicked it come out fine but if it is clicked again all the rows of the gridview are displayed irrespective of data and they disappear again when clicked and then reappear if next is pressed .
|
|
|
|
|
Look at this and compare
Paging without a wizard (SqldataSource control) [^]Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
you have to post some sample code also, to clarify this problem.
|
|
|
|
|
protected override void InitializePager(GridViewRow row, int columnSpan, PagedDataSource pagedDataSource)
{
try
{
if (PagerType == ThisPagerType.Regular)
{
try
{
if (CustomPaging)
{
pagedDataSource.AllowCustomPaging = true;
pagedDataSource.VirtualCount = VirtualItemCount;
pagedDataSource.CurrentPageIndex = CurrentPageIndex;
}
base.InitializePager(row, columnSpan, pagedDataSource);
}
catch (Exception ex)
{
throw ex;
}
}
else
{
pagedDataSource.AllowCustomPaging = true;
pagedDataSource.VirtualCount = VirtualItemCount;
pagedDataSource.CurrentPageIndex = CurrentPageIndex;
PlaceHolder plc = new PlaceHolder();
TableCell cell_0 = new TableCell();
TableCell cell_1;
{
cell_1 = new TableCell();
LinkButton prev = new LinkButton();
prev.Text = "<< Previous ";
prev.CommandArgument = string.Format("{0}", (pagedDataSource.CurrentPageIndex - 1));
prev.Visible = (pagedDataSource.CurrentPageIndex > 0);
prev.CssClass = "pagnPrev";
prev.Click += new EventHandler(navigate_Click);
cell_1.Controls.Add(prev);
for (int i = 0; i < pagedDataSource.PageCount; i++)
{
LinkButton numb = new LinkButton();
numb.ID = i.ToString();
numb.Text = Convert.ToString(i + 1);
numb.CommandArgument = string.Format("{0}", Convert.ToString(i));
if (i == pagedDataSource.CurrentPageIndex)
{
numb.Enabled = false;
numb.CssClass = "pagnCur";
}
else
{
numb.Enabled = true;
numb.CssClass = "pagnLink";
}
numb.Click += new EventHandler(navigate_Click);
cell_1.Controls.Add(numb);
if (i < pagedDataSource.PageCount)
{
Literal ltl = new Literal();
ltl.Text = " ";
cell_1.Controls.Add(ltl);
}
}
LinkButton next = new LinkButton();
next.Text = "Next >>";
next.CommandArgument = string.Format("{0}", (pagedDataSource.CurrentPageIndex + 1));
next.Visible = (pagedDataSource.CurrentPageIndex < (pagedDataSource.PageCount - 1));
next.CssClass = "pagnNext";
next.Click += new EventHandler(navigate_Click);
cell_1.Controls.Add(next);
}
// create a Table that will replace entirely our GridView's Pager section
Table tbl = new Table();
tbl.BorderWidth = 0;
tbl.Width = Unit.Percentage(100);
tbl.Rows.Add(new TableRow());
tbl.Rows[0].Cells.Add(cell_1);
tbl.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Right;
row.Controls.AddAt(0, new TableCell());
row.Cells[0].ColumnSpan = Columns.Count;
row.Cells[0].Controls.AddAt(0, tbl);
if ((FooterText != null) && (FooterURL != null))
{
Literal ltlLink = new Literal();
ltlLink.Text = @"<a href="""+ FooterURL +@""" title="""+ FooterText+ @""" target=""_self"">" + FooterText + "</a>";
this.FooterRow.Cells[0].Controls.Add(ltlLink);
}
else if (FooterText != null)
this.FooterRow.Cells[0].Text = FooterText;
}
}
public virtual void LoadGrid(MailSearch mailSearch, userAccount ,int pageCount)
{
try
{
mailSearch.PageSize = 20;
mailSearch.SelectedPage = pageCount;
MailResults mailResults = new MailResults();
//sent messages
if (ViewState["ReceivedFlag"] == null)
{
mailSearch.FromPartyId = userAccount.PartyId;
mailResults = userAccount .MailSearch(mailSearch, Helper.GetLoggedInIdentity());
}
//received messages
else if (ViewState["ReceivedFlag"].ToString() == "true")
{
mailResults = userAccount.MailSearchByReceivedMessages(mailSearch, userAccount.PartyId, Helper.GetLoggedInIdentity());
}
//sent messages
else if (ViewState["ReceivedFlag"].ToString() == "false")
{
mailSearch.FromPartyId = userAccount.PartyId;
mailResults = userAccount.MailSearch(mailSearch, Helper.GetLoggedInIdentity());
}
if (mailResults.MailCollection.Count == 0)
{ lblXYZ.Text = "Currently, You don't have ....."; }
else
{
int size;
if ((mailResults.RowCount) < (pageCount * 20))
{ size = (int)mailResults.RowCount; }
else { size = (pageCount * 20); }
lblXYZ.Text = "Mail ( " + ((pageCount * 20) - 19) + "-" + size + " of " + mailResults.RowCount + ")";
}
DataTable dt = new DataTable();
dt.Columns.Add("MailID");
dt.Columns.Add("FromUserName");
dt.Columns.Add("Subject");
dt.Columns.Add("CreatedDate");
dt.Columns.Add("LastViewedDate");
dt.Columns.Add("dteCreatedDate");
dt.Columns.Add("dteLastViewedDate");
DataRow drow;
foreach (Mail mail in mailResults.MailCollection)
{
drow = dt.NewRow();
drow["MailID"] = mail.MailId;
drow["FromUserName"] = mail.FromUserName;
drow["Subject"] = mail.Subject;
drow["CreatedDate"] = mail.CreatedDate.ToString("dd/MM/yyyy HH:mm");
if (!String.IsNullOrEmpty(mail.LastViewedDate.ToString()))
drow["LastViewedDate"] = mail.LastViewedDate.Value.ToString("dd/MM/yyyy HH:mm");
else
drow["LastViewedDate"] = mail.LastViewedDate;
drow["dteCreatedDate"] = mail.CreatedDate;
drow["dteLastViewedDate"] = mail.LastViewedDate;
dt.Rows.Add(drow);
}
this.gvMail.PageSize = mailSearch.PageSize.Value;
this.gvMail.VirtualItemCount = mailResults.RowCount.Value;
this.gvMail.CurrentPageIndex = pageCount - 1;
gvMail.DataSource = dt;
gvMail.DataBind();
}
catch (Exception ex)
{
xyz
throw;
}
}
|
|
|
|
|
Hi all,
I have a problem in my site that, when i call the java script in on load, it jsut going on loop. my code here
<script type="text/javascript">
function coolAl() {
alert("The page is loading... now!");
document.getElementById("PageRun").click();
}
</script>
<body onLoad="coolAl()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
where PageRun is an asp button which has some events on the aspx.cs page
even the events code is empty am getting looped.
it gets stopped when i remove
document.getElementById("PageRun").click();
what may be the reason. help me pleaser
|
|
|
|
|
An ASP.NET button causes a postback which reloads the page. You tell me why you're in a loop. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi, I'm having a strange problem when I'm testing my custom web control. The problem is when I have entered a value in the textbox and pressed next on to another screen. If I then go back (history.back) then the textbox is blank rather than showing the value entered.
This only seems to happen in Firefox and Chrome though and it is fine in IE. The value is being saved to the database ok. My class in inheriting from WebControl.
public class AutoCompleteTextBox : WebControl
If it helps, there is a lot of JavaScript used.
Does anybody have any idea how I can solve this please?
Thanksmodified on Monday, February 8, 2010 11:03 AM
|
|
|
|
|
Hello.
I wanna make a webpage to find ID or password.
If someone lost his password, the page should let him know his password by email.
so, I should make a function to send an email to be able to check out the password or new password.
Is there any good sample source??
please let me know how to make it..
Thank you.
|
|
|
|
|
Use the builtin ASP.NET login controls and database. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
rapidshare,hotfile and many site they restric user to download more than one file at a time.
what is their concept and how can i implement this concept by asp.net
thankstbhattacharjee
|
|
|
|
|
|
HI All,
Need some suggestions.
suppose, I have a free Blog hosting site like blogspot.com and i want to restrict each blog size to not more than 20MB,to do this i need to calculate the size of the Blog hosted on the server
how do i calculate the size of every blog?
Thanks in advance,Satish
|
|
|
|
|
You need to ask google, if there is no info regarding the blog size.
You cant calculate yourself, as it is not in your own server.
|
|
|
|
|
how to download a large file with resume facility in asp.net. thanks tbhattacharjee
|
|
|
|
|
You could have a look at BITS - Background Intelligent Transfer Service
|
|
|
|
|
is it possible to download any zip file to client machine through icallback. please help me with a sample code.
Thanks in advancetbhattacharjee
|
|
|
|
|
i hard that partial postback like effect can be achived by using IFrame.so can anyone help me with few sample code to get the partial postback like effetct by IFRAME.Thanks in advance. tbhattacharjee
|
|
|
|
|
|
Hi,
I'm developing a user control that is loaded dynamically into a page.
The user control has 4 dropdownlists(DDLs). Each is populated dynamically depending upon the values selected in the previous DDLs. Each DDL is in a separate updatepanel (not nested) and has the autopostback set true. Each has its trigger set as the SelectedIndexChanged event of the DDL before it.
The problem is, if the user selects a (non default) selection 'x' in the first DDL and tries to select something say 'p' in DDL2, on postback, SelectionChangedEvent for DDL1 is fired (as per normal page lifecycle) to select 'x' which reloads DDL2 before SelectionChangedEvent of DDL2 is fired. This causes the selected 'p' in DDL2 to be lost and the page comes back again with the default selection for DDL2. Similar is the case with other DDLs. Here's the logic of my code:
Page_Load()
{
//Load DDL1
}
UpdatePanel2_Load()
{
//Load DDL2
}
UpdatePanel3_Load()
{
//Load DDL3
}
UpdatePanel4_Load()
{
//Load DDL4
}
OnSelectedIndexChanged_DDL1()
{
//Load DDl2,DDL3,DDL4
}
OnSelectedIndexChanged_DDL2()
{
//Load DDL3,DDL4
}
OnSelectedIndexChanged_DDL3()
{
//Load DDL4
}
What this does is, when OnSelectedIndexChanged_DDL1() is fired on postback to select 'x' in DDL1, it reloads DDL2,DDL3,DDL4 and by the time OnSelectedIndexChanged_DDL2() is fired (because of the selection 'p' made by user) the statement 'DDL2.SelectedValue' inside it only returns the default DDL2 selection 'd' and not the user selection 'p'. Can I get the value selected by the user in Page_Load itself (say from Viewstate) instead of waiting for OnSelectedIndexChanged_DDL2() to fire?
I know it's really long and might seem confusing but I really need a solution to this and am losing my mind! Any help would be great. Thanks
|
|
|
|
|
hi all i tried creating a web service.it is being created successfully.
but there is no bin folder and no bin/webservice.dll I created web service as a new project.
and a new directory.Can any body give me some gud link or article which is self suffficeint
to understand web service.How we can deploy the web service on the net.also i am confused
about the diffrence in webservices created as a individual project(as mine) and one which
is created inside our our website.what is the diffrence.how to use the web service in our application.plz guide me.thanks...
regards..
|
|
|
|
|
|
thanks the article is self sufficient.....
|
|
|
|