|
Hello,
I need help, i want to list a content from specific folder from FTP, a can make the connection to FTP, but i don't know how can list the files contended in a specific Folder from FTP in one ListBox.
Thank's for you time, i'm new ( beginner) in .NET
Thank's again !
This is my code in C#
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create("ftp://server.com");
Request.Method = WebRequestMethods.Ftp.ListDirectory;
Request.Credentials = new NetworkCredential("user", "pass");
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Stream ResponseStream = Response.GetResponseStream();
StreamReader Reader = new StreamReader(ResponseStream);
//ListBox1.Items.Add(Response.BannerMessage);
//ListBox1.Items.Add(Response.WelcomeMessage);
while (!Reader.EndOfStream)//Read file name
{
ListBox1.Items.Add(Reader.ReadLine().ToString());
}
Response.Close();
ResponseStream.Close();
Reader.Close();
}
}
and i have one folder ftp;//server.com/FolderX/
i want to list the files from FolderX in one ListBox and in one label to show me the numbers of files from FolderX
Many thamks
|
|
|
|
|
hi
actualy i want to create dynamic menu accroding to permission of user.
it should get generate dynamically.....
for that i used database...there are three tables related to menus
1. tblModule -which contains module code and module description i.e. masters,search,rate entry
2. tblMenu- which contains menucode,menu desc.(bus,car,flight,train),modulecode.
3. tblSubMenu-which contains submenucode,submenuname(add new bus,del bus,modify bus,search bus,add new rate entry
for bus ...etc),submenulinks(means path of aspx file i.e. Masters/bus/newBusEntery.aspx),menucode
now i want to dynamically create menus according to permissions like bus|car|flight...
after clicking on bus it should display the submenu in dropdown manner like this,
-add new bus
-modify bus
-delete bus
and after selecting add new bus it should display the 'newBusEntery.aspx' page which is in Masters/bus folder
whose path is stored in tblSubMenu table..
please, give code samples i need it urgently and i am new in asp.net,so help me friends....
thanx..
|
|
|
|
|
Hi to all forum members.
I am stuck in implementing ModalPopupExtender in <asp:CommandField in grid view.
Although below code is working fine in <asp:template field in grid view.
<asp:TemplateField HeaderText="Delete" HeaderStyle-CssClass="tableheading" HeaderStyle-Width="70px">
<ItemTemplate>
<center>
<asp:ImageButton ID="imgDelete" runat="server" OnClientClick="showConfirm(this); return false;"
ImageUrl="~/Images/delete.png" OnClick="imgBtnDelete_Click" /></center>
</ItemTemplate>
</asp:TemplateField>
following is my code which I am trying to implement in <asp:CommandFiel in grid view.
.aspx code
Grid view code
<asp:CommandField HeaderText="Edit/Delete" ItemStyle-HorizontalAlign="Center" CausesValidation="false"
ShowCancelButton="true" ShowEditButton="True" ShowDeleteButton="true" />
modal popup code
<ajaxToolkit:ModalPopupExtender ID="md1" runat="server" BackgroundCssClass="modalBackground"
BehaviorID="mdlPopup" CancelControlID="btnNo" OkControlID="btnOk" OnCancelScript="cancelClick();"
OnOkScript="okClick();" PopupControlID="Confiramtiondiv" TargetControlID="Confiramtiondiv">
</ajaxToolkit:ModalPopupExtender>
<div id="Confiramtiondiv" runat="server" align="center" style="display: none">
<table id="Table3" cellpadding="1" cellspacing="1" border="0" bordercolor="blue"
runat="server" align="center">
<tr>
<td colspan="4" align="center">
<asp:Label ID="lblConfirmmsg" runat="server" Text="Are you sure you want to delete this Trip ?"
CssClass="lblConfirmmsg"></asp:Label>
</td>
</tr>
<tr>
<td width="20%">
</td>
<td width="30%">
<asp:Button ID="btnOk" runat="server" Text="Yes" CausesValidation="false" Width="50px" />
</td>
<td width="30%">
<asp:Button ID="btnNo" runat="server" CausesValidation="false" Text="No" Width="50px" />
</td>
<td width="20%">
</td>
</tr>
</table>
</div>
.cs code
protected void grdTrips_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState != DataControlRowState.Edit) // check for RowState
{
if (e.Row.RowType == DataControlRowType.DataRow) //check for RowType
{
string id = e.Row.Cells[0].Text; // Get the id to be deleted
LinkButton lb = (LinkButton)e.Row.Cells[8].Controls[2]; //cast the ShowDeleteButton link to linkbutton
if (lb != null && lb.Text == "Delete")
{
lb.Attributes.Add("onclick", "showConfirm(this); return false;"); //implementing Ajax modal popup extender
}
}
}
Java Script Function
// keeps track of the delete button for the row
// that is going to be removed
var _source;
// keep track of the popup Confiramtiondiv
var _popup;
function showConfirm(source){
this._source = source;
this._popup = $find('mdlPopup');
// find the confirm ModalPopup and show it
this._popup.show();
}
function okClick(){
// find the confirm ModalPopup and hide it
this._popup.hide();
// use the cached button as the postback source
__doPostBack(this._source.name, '');
}
function cancelClick(){
// find the confirm ModalPopup and hide it
this._popup.hide();
// clear the event source
this._source = null;
this._popup = null;
}
This code opens modal popup but its does not goes to RowDeleting Event of gridview
.
When I changed this code
lb.Attributes.Add("onclick", "showConfirm(this); return false;");
to
lb.Attributes.Add("onclick", "showConfirm(this);");
it open the modal popup but then directly goes to to grid view RowDeleting Event of gridview with out asking confirmation from the users.
I again told this code is working fine in <asp:templatefield.
Welcome for your valuable suggestionsVishnu Narayan Mishra
Software Engineer
|
|
|
|
|
hi,
i have useing asp.net 2.0 and ajax extension.
i have pass 3 value to popup window...if update some values in child(popup) window. its automatically refresh particular (update panel or) gridview in parent page.
i have code for refresh parent window. but i dont have code for refresh particular window.Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
are you using that popup from same page or open popup from another page?
|
|
|
|
|
(New) another page Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
Dear all,
I was doing a calculation on the total of costs using datagrid. There are only two row in my data. I use the following to insert the summary to the footer but is not success which is as below:
For RawCount = 0 To ItemCount - 1
Quantity(RawCount) = Me.dtGrid.Items(RawCount).Cells(2).Text
Price(RawCount) = Me.dtGrid.Items(RawCount).Cells(5).Text
Costs(RawCount) = Quantity(RawCount) * Price(RawCount)
Me.dtGrid.Items(RawCount).Cells(6).Text = Costs(RawCount)
TotalQuantity = Quantity(RawCount) + TotalQuantity
TotalCost = TotalCost + Costs(RawCount)
If Me.dtGrid.Items(RawCount).ItemType = ListItemType.Footer Then
Me.dtGrid.Items(RawCount).Cells(2).Text = TotalQuantity
End If
Could anyone please help me check what is the problem and why the data is not display in my footer raw?
Thank you so much for the help!
|
|
|
|
|
Please refer from Here[^]
|
|
|
|
|
Hi all,
Use the google graph API if you need any graph requirement in your application, its really good
See the example:
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["piechart"]});
google.setOnLoadCallback(drawPieChart);
// google.load("visualization", "1", {packages:["barchart"]});
// google.setOnLoadCallback(drawBarChart);
function drawBarChart() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn('number', 'Expenses');
data.addColumn('number', 'Expenses1');
data.addColumn('number', 'Expenses2');
data.addColumn('number', 'Expenses3');
data.addColumn('number', 'Expenses4');
data.addColumn('number', 'Expenses5');
data.addColumn('number', 'Expenses6');
data.addColumn('number', 'Expenses7');
data.addColumn('number', 'Expenses8');
data.addColumn('number', 'Expenses9');
data.addRows(1);
data.setValue(0, 0, '');
data.setValue(0, 1, 1000);
data.setValue(0, 2, 400);
data.setValue(0, 3, 700);
data.setValue(0, 4, 40);
data.setValue(0, 5, 90);
data.setValue(0, 6, 480);
data.setValue(0, 7, 120);
data.setValue(0, 8, 100);
data.setValue(0, 9, 400);
data.setValue(0, 10, 200);
data.setValue(0, 11, 100);
new google.visualization.BarChart(document.getElementById('chart_div')).
draw(data, {width: 600, height: 440, is3D: true});
}
function drawPieChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Expense Item');
data.addColumn('number', 'Expense');
data.addRows(8);
data.setValue(0, 0, 'Food');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Drinks');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Cinima');
data.setValue(2, 1, 2);
data.setValue(3, 0, 'party');
data.setValue(3, 1, 2);
data.setValue(4, 0, 'smoke');
data.setValue(4, 1, 7);
data.setValue(5, 0, 'smoke2');
data.setValue(5, 1, 7);
data.setValue(6, 0, 'smoke3');
data.setValue(6, 1, 7);
new google.visualization.PieChart(document.getElementById('chart_div')).
draw(data,{width: 600, height: 440, is3D: true});
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>dhdh
|
|
|
|
|
Hey its nice. thank you. But can you give any URL for this. Naina
|
|
|
|
|
|
|
Hi,
I want "Enter" Key press count fro .doc file. I am using ASCII value of "Enter" Key . But How can I find using stramreader while reading file.
Or any other Solution for that?
Thanks,
sjs
|
|
|
|
|
Well, it doesn't seems to be related to Asp.net.
I think C# forum will be more suitable for this question.
Anyways, streamReader may not work for this.
Read your word file text using Microsoft Word Object library,
and get the text in the string. After that you can easily find
"\r\n" characters in your text.
|
|
|
|
|
Hi,
on pressing enter button to submit the login details it is working in IE but it is not working in Firefox could anyone help iam using the javascript function
function doClick(buttonName,e)
{
//the purpose of this function is to allow the enter key to
//point to the correct button to click.
var key ;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
if (key == 13)
{
//Get the button the user wants to have clicked
var btn = document.getElementById(buttonName);
if (btn != null)
{ //If we find the button click it
btn.click();
event.keyCode = 0
}
}
}
Thanks & Regards,
Nath
|
|
|
|
|
I am newbie to webservices
I am trying to learn about them, but got struck in the first place itself. Please help me out.
My service.cs in the web service.
--------------------------------
using System;<br />
using System.Web;<br />
using System.Web.Services;<br />
using System.Web.Services.Protocols;<br />
<br />
[WebService(Namespace = "http://localhost:1458/forumservices/")]<br />
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
public class Service : System.Web.Services.WebService<br />
{<br />
public Service () {<br />
<br />
}<br />
<br />
<br />
[WebMethod]<br />
public string welcome(string name)<br />
{<br />
return "Welcome " + name;<br />
}<br />
<br />
}
now on a button click from another web page
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
try<br />
{<br />
soapMessage =<br />
@"<br />
<?xml version=""1.0"" encoding=""utf-8""?><br />
<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope""><br />
<soap12:Body><br />
<welcome xmlns=""http://localhost:1458/forumservices/""><br />
<name>Rajas</name><br />
</welcome><br />
</soap12:Body><br />
</soap12:Envelope>";<br />
<br />
WebClient mClient = new WebClient();<br />
<br />
<br />
<br />
Response.Write(System.Text.Encoding.ASCII.GetString(mClient.UploadData("http://localhost:1458/forumservices/Service.asmx", "POST", System.Text.Encoding.ASCII.GetBytes(soapMessage))));<br />
}<br />
catch (System.Net.WebException ex)<br />
{<br />
if (ex.Response != null)<br />
{<br />
Stream strm = ex.Response.GetResponseStream();<br />
StreamReader sr = new StreamReader(strm);<br />
Response.Write(sr.ReadToEnd());<br />
}<br />
else<br />
{<br />
Response.Write(ex.InnerException.ToString());<br />
}<br />
}<br />
<br />
}
The compilation is fine, but i keep getting some errors as below
"The remote server returned an error: (500) Internal Server Error."
Please help me outJack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
According to me to consume webservice in you application you need to add webreferace of webservice in you application
than to call web service you need to create objct of that and than you can call webservice.
Check on following link which give you idea about how to consume website.
<a href="http://it.toolbox.com/wiki/index.php/Calling_a_web_service_from_Asp.net">http://it.toolbox.com/wiki/index.php/Calling_a_web_service_from_Asp.net</a>[<a href="http://it.toolbox.com/wiki/index.php/Calling_a_web_service_from_Asp.net" target="_blank" title="New Window">^</a>]
|
|
|
|
|
|
Sashi,
When I call it using web reference it is working fine.
But I have to manually call the web service using xml+soap. got any ideasJack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
No Brother..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Hi all,
in my website i need to concatenate some memory streams and export like
response.binarywrite(memorystream.toarray())
in the memory stream i need to concatenate some more memory streams also,
how to do this, is it possible by means of changing by bytes or something like that??
please help me
|
|
|
|
|
Do you mean something like this?
MemoryStream MS1 = new MemoryStream(new byte[] { 0x01, 0x02, 0x03 });
MemoryStream MS2 = new MemoryStream(new byte[] { 0x04, 0x05, 0x06 });
MemoryStream MS3 = new MemoryStream();
MS3.SetLength(MS1.Length + MS2.Length);
MS3.Write(MS1.ToArray(), 0, (int)MS1.Length);
MS3.Write(MS2.ToArray(), 0, (int)MS2.Length);
Byte[] Result = MS3.ToArray();
foreach (Byte B in Result)
Response.Write(B.ToString() + " ");
Steve Wellens
|
|
|
|
|
thanks for your response,
i tried this code,
but in your code the second line MS3.write will over write(replace) the MS1.
that is my problem here as i am unable to write over, can you tell me more please
|
|
|
|
|
Really?
I included test output and it looked like this:
1 2 3 4 5 6
Nothing was overwritten.Steve Wellens
|
|
|
|
|
DataTable dt = new DataTable();
dt = _dal.ExecuteQuery_Out("select * from table1");
ReportDocument[] rd = new ReportDocument[2];
rd[0] = new ReportDocument();
rd[0].Load(Server.MapPath("ResultReport.rpt"));
rd[0].SetDataSource(dt);
dt = new DataTable();
dt = _dal.ExecuteQuery_Out("select * from table2");
rd[1] = new ReportDocument();
rd[1].Load(Server.MapPath("ResultReport.rpt"));
rd[1].SetDataSource(dt);
MemoryStream Parent1 = new MemoryStream();
MemoryStream[] Parentar = new MemoryStream[2];
byte[] parent = new byte[2];
//MemoryStream Mem;
//Mem = (MemoryStream)rd1.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
//byte[] bytearray = Mem.ToArray();
int h = 1;
for (int i = 0; i < rd.Length; i++)
{
Parentar[i] = (MemoryStream)rd[i].ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
//Array.Copy(Mem.ToArray(), parent, h);
//h++;
//((byte[])Mem.ToArray()).CopyTo(parent, h);
//h = ((byte[])Mem.ToArray()).Length + 1;
}
long length = 0;
for (int i = 0; i < Parentar.Length; i++)
{
length += Parentar[i].Length;
Parentar[i].Close();
}
Parent1.SetLength(length);
for (int i = 0; i < Parentar.Length; i++)
{
/* your code*/
Parent1.Write(Parentar[i].ToArray())
/* my code*/
byte[] b = Parentar[i].ToArray();
foreach (byte b1 in b)
Parent1.WriteByte(b1);
}
Parent1.Close();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(Parent1.ToArray());
here i should get both the report documents result in the pdf,
am i correct..
actually simulatenously i was working and i did some codes though here..
but am getting the last things in the out put..am i not dealing with the streams correctly like closing at appropriate place?
even in the debug mode the Parent1 current postiion is increasing while looping the second one..but am not getting
|
|
|
|
|