|
Yeah, I think so....
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Are you putting the whole stuff inside a loop which is missing from your above code ? If yes put the message box.Show outside the loop
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
thanks..I am still struck with loop, could you please provide me template/sample code..it will be good help
|
|
|
|
|
Bit hard to give you something exact, would need more info about your app/design but this is the basics:
foreach (Control c in myCollection)
{
if (c.someProperty == true)
{
}
else
{
}
}
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Thanks a lot.....I am providing you exact code
DialogResult dlgResult = MessageBox.Show("Removal of this task will also remove following tasks:" + "(" + next_node + ")" + " Do you still want to continue", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (!selectedNode.Checked)
if (dlgResult == DialogResult.Yes)
doCheckSibling(next_node, false);
else if (dlgResult == DialogResult.No)
selectedNode.Checked = true;
This will give you better idea and you can tell me exactly how I can use foreach, I am very close to solution I hope this would be my last query...thanks in advance..
|
|
|
|
|
I have already told you exactly how to use a foreach, I'm not here to do your work for you and if I was to give you complete code you won't learn anything. You've also provided me with the same snippet from your original post. I suggest you look at my last post, consider what issue you're having and then read the following article: How To Use Google[^]
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
hi, i have some problems with httpwebrequest
i'm trying to make my adsl router to restart the internet connection using httpwebrequests but it always returning me
the same response/login page
and my cookie container is always empty(count =0)
here is my code:
<br />
<br />
using System;<br />
<br />
using System.IO;<br />
<br />
using System.Net;<br />
<br />
using System.Text;<br />
<br />
namespace HTTPreconnector<br />
<br />
{<br />
<br />
class Program<br />
<br />
{<br />
<br />
static void Main(string[] args)<br />
<br />
{<br />
<br />
Reconnect();<br />
<br />
Console.Read();<br />
<br />
}<br />
<br />
<br />
<br />
public static void Reconnect()<br />
<br />
{<br />
<br />
String url = @"http://10.0.0.138/";<br />
<br />
String strPost = @"var%3Amain=menu1&var%3Astyle=style1&getpage=..%2Fhtml%2Fdefs%2Fstyle1%2Fmenus%2Fmenu1.html&errorpage=..%2Fhtml%2Findex.html&var%3Apagename=home&var%3Aerrorpagename=home&var%3Amenu=quickstart&var%3Amenutitle=Quickstart&var%3Apagetitle=Quick+Start&var%3Apagemaster=home&login%3Acommand%2Fusername=Admin&login%3Acommand%2Fpassword=Admin&var%3Arestore=0";<br />
<br />
StreamWriter myWriter = null;<br />
<br />
CookieContainer myContainer = new CookieContainer();<br />
<br />
<br />
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);<br />
<br />
objRequest.Method = "POST";<br />
<br />
objRequest.ContentLength = strPost.Length;<br />
<br />
objRequest.ContentType = "application/x-www-form-urlencoded";<br />
<br />
objRequest.CookieContainer = new CookieContainer();<br />
<br />
try<br />
<br />
{<br />
<br />
myWriter = new StreamWriter(objRequest.GetRequestStream());<br />
<br />
myWriter.Write(strPost);<br />
<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
<br />
Console.WriteLine(e.Message);<br />
<br />
}<br />
<br />
finally<br />
<br />
{<br />
<br />
myWriter.Close();<br />
<br />
}<br />
<br />
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();<br />
<br />
<br />
foreach (Cookie cook in objResponse.Cookies)<br />
<br />
{<br />
<br />
myContainer.Add(cook);<br />
<br />
}<br />
<br />
using (StreamReader sr =<br />
<br />
new StreamReader(objResponse.GetResponseStream()))<br />
<br />
{<br />
<br />
String test = sr.ReadToEnd();<br />
<br />
sr.Close();<br />
<br />
Console.WriteLine(test);<br />
<br />
}<br />
<br />
<br />
objRequest = (HttpWebRequest)WebRequest.Create(url);<br />
<br />
strPost = strPost = @"var%3Amain=menu1&var%3Astyle=style1&getpage=..%2Fhtml%2Fdefs%2Fstyle1%2Fmenus%2Fmenu1.html&errorpage=..%2Fhtml%2Fstatus%2Fconnection.html&var%3Apagename=home&var%3Aerrorpagename=home&var%3Amenu=quickstart&var%3Amenutitle=Quickstart&var%3Apagetitle=Quick+Start&var%3Apagemaster=home&var%3AconnectBtnPressed=&var%3Aconid=connection0&connection0%3Apppoe%3Acommand%2Fstop=";<br />
<br />
objRequest = (HttpWebRequest)WebRequest.Create(url);<br />
<br />
objRequest.Method = "POST";<br />
<br />
objRequest.ContentLength = strPost.Length;<br />
<br />
objRequest.ContentType = "application/x-www-form-urlencoded";<br />
<br />
objRequest.CookieContainer = myContainer;<br />
<br />
try<br />
<br />
{<br />
<br />
myWriter = new StreamWriter(objRequest.GetRequestStream());<br />
<br />
myWriter.Write(strPost);<br />
<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
<br />
Console.WriteLine(e.Message);<br />
<br />
}<br />
<br />
finally<br />
<br />
{<br />
<br />
myWriter.Close();<br />
<br />
}<br />
<br />
objResponse = (HttpWebResponse)objRequest.GetResponse();<br />
<br />
using (StreamReader sr =<br />
<br />
new StreamReader(objResponse.GetResponseStream()))<br />
<br />
{<br />
<br />
String test = sr.ReadToEnd();<br />
<br />
sr.Close();<br />
<br />
Console.WriteLine(test);<br />
<br />
}<br />
<br />
foreach (Cookie cook in objResponse.Cookies)<br />
<br />
{<br />
<br />
myContainer.Add(cook);<br />
<br />
}<br />
<br />
System.Threading.Thread.Sleep(6200);<br />
<br />
<br />
objRequest = (HttpWebRequest)WebRequest.Create(url);<br />
<br />
strPost = strPost = @"var%3Amain=menu1&var%3Astyle=style1&getpage=..%2Fhtml%2Fdefs%2Fstyle1%2Fmenus%2Fmenu1.html&errorpage=..%2Fhtml%2Fstatus%2Fconnection.html&var%3Apagename=home&var%3Aerrorpagename=home&var%3Amenu=quickstart&var%3Amenutitle=Quickstart&var%3Apagetitle=Quick+Start&var%3Apagemaster=home&var%3AconnectBtnPressed=1&var%3Aconid=connection0&connection0%3Apppoe%3Acommand%2Fstart=";<br />
<br />
objRequest = (HttpWebRequest)WebRequest.Create(url);<br />
<br />
objRequest.Method = "POST";<br />
<br />
objRequest.ContentLength = strPost.Length;<br />
<br />
objRequest.ContentType = "application/x-www-form-urlencoded";<br />
<br />
objRequest.CookieContainer = myContainer;<br />
<br />
try<br />
<br />
{<br />
<br />
myWriter = new StreamWriter(objRequest.GetRequestStream());<br />
<br />
myWriter.Write(strPost);<br />
<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
<br />
Console.WriteLine(e.Message);<br />
<br />
}<br />
<br />
finally<br />
<br />
{<br />
<br />
myWriter.Close();<br />
<br />
}<br />
<br />
objResponse = (HttpWebResponse)objRequest.GetResponse();<br />
<br />
using (StreamReader sr =<br />
<br />
new StreamReader(objResponse.GetResponseStream()))<br />
<br />
{<br />
<br />
String test = sr.ReadToEnd();<br />
<br />
sr.Close();<br />
<br />
Console.WriteLine(test);<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
thanks!
|
|
|
|
|
Member 4290786 wrote: and my cookie container is always empty(count =0)
Member 4290786 wrote: CookieContainer myContainer = new CookieContainer();
Member 4290786 wrote: objRequest.CookieContainer = new CookieContainer();
Need I say more?
|
|
|
|
|
Hello.
Friends,
I am trying to add Web reference in windows application but problem is that in place of web reference .NET 3.5 showing Service reference. and tell how to use.
Thanks,
RPSingh
|
|
|
|
|
Shows up in my VS2008 Professional.
|
|
|
|
|
Hi,
I am setting a Property in a class using the following:
xmloutput.FileName = @"c\projects\text.xml";
Then I use the following to open a new XMLTextWriter;
XmlTextWriter xmlWriter = new XmlTextWriter(_FileName, System.Text.Encoding.UTF8);
However the Filename gets changed to :
D:\\My Documents\\Visual Studio 2005\\Projects\\Scanner\\Scanner\\bin\\Debug\\c\\projects\\text.xml
I cannot understand why the D:\\ etc gets put onto the front of the string. Any help would be appreciated
|
|
|
|
|
Not sure if this is 100% the issue, but I'm assuming 'c' is a drive and not a folder. Set the filename to @"C:\\projects\\text.xml"
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
When you put a @ in front of the string you don't need \\ to get a \. But otherwise it's correct. There is a : missing in the path.
|
|
|
|
|
Thanks everyone I could not see the wood for the trees. Just spotted the : missing. Thanks again
|
|
|
|
|
Because the sting you are passing isn't a valid path so your program thinks it is a relative path and appends it to the current directory of your application.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi,
Thanks for the responses. However, c:\projects does exist on my PC and I have also tried @c:\\projects but am still getting the same problem. However if I hard code as in the following it works fine.
XMLDoc.Save(@"c:\projects\text.xml")
|
|
|
|
|
May be it is taking what you gave in the xmlDoc.FileName as the FILENAME and not the actual path. So the batch will be now [Default solutionpath]\FileName.
In the lter case the Save accepts the actuall path to the file and works fine.
May be you can try storing the path differently nad get it to the scene only in the save function
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
c:\projects is a folder, not a file so how can xmlwriter write to it? You need to specify file path. If you need to path of folder for something else try this: @C:\projects\
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Simple problem. See if you can spot the difference:
xmloutput.FileName = @"c\projects\text.xml";
xmloutput.FileName = @"c:\projects\text.xml";
In essence the path you specified is not what you had intended. You meant to specify an absolute path. The compiler didn't detect the drive (c and treats the whole thing as path relative to wherever the application is being run from. In your case the bin\Debug.
|
|
|
|
|
hi
i added a combobox and dateTimePicker in datagrid columns.These controls are working properly.But whenever any value is selected from these controls, the datagrid is not get edited.i mean that no new row is added to datagrid,hence the datagrid is appearing with one row only.There are 3 columns in datagrid two with comboboxes and one DateTimePicker.
how to solve this problem?
here is the code i had written
sFromCb=new ComboBox();<br />
sFromCb.Cursor = System.Windows.Forms.Cursors.Arrow;<br />
sFromCb.DropDownStyle = ComboBoxStyle.DropDownList;<br />
sFromCb.Width = 100;<br />
sFromCb.SelectionChangeCommitted +=new EventHandler(sFromCb_SelectionChangeCommitted);<br />
<br />
DataGridTextBoxColumn fromcol=new DataGridTextBoxColumn();<br />
fromcol.MappingName = dtCore.Columns[i].ColumnName; <br />
fromcol.HeaderText = fromcol.MappingName;<br />
fromcol.Width=100;<br />
fromcol.ReadOnly=true;<br />
fromcol.TextBox.Enter +=new EventHandler(fromcolTextBox_Enter);<br />
fromcol.TextBox.Leave +=new EventHandler(fromcolTextBox_Leave);<br />
fromcol.TextBox.Controls.Add(sFromCb);<br />
tableStyle.GridColumnStyles.Add(fromcol);<br />
<br />
private void sFromCb_SelectionChangeCommitted(object sender, EventArgs e)<br />
{<br />
dataGrid1[dataGrid1.CurrentCell] = ((ComboBox)sender).SelectedItem.ToString(); }<br />
<br />
private void fromcolTextBox_Enter(object sender, EventArgs e)<br />
{<br />
((TextBox)sender).Visible=true;<br />
sFromCb.SelectedItem=((TextBox)sender).Text;<br />
sFromCb.Focus();<br />
}<br />
private void fromcolTextBox_Leave(object sender, EventArgs e)<br />
{<br />
((TextBox)sender).Text=dataGrid1[dataGrid1.CurrentCell].ToString();<br />
((TextBox)sender).Visible=false;<br />
} The items in combobox is coming from a dataset.
Thanks in advance for help
|
|
|
|
|
hello
i want to add submit button on grid view control.
pls tell me code.
gayatri
Gayatri
|
|
|
|
|
Submit to where?
Changes are always written to the DataSource, but that doesn't mean that they are written to the database or file that the data comes from. That you have to write code for. If this is what you want to do you must be more specific on what the source is. There is also a lot of examples on how to do this on MSDN and internet.
|
|
|
|
|
thanku sir
sir i want button in one column.
when i click on that button that time the values are display on textbox etc.
so pls help me.
gayatri
Gayatri
|
|
|
|
|
I'm looking for a working FTP server class / code in C#, preferably without interface. Any help would be great.
|
|
|
|
|
Please help me how do i c orrect this errors
|
|
|
|