|
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
comboBox1.SelectedIndex = 0;<br />
webBrowser1.GoHome();<br />
}<br />
this would initialize the combobox way where i can input populate the combobox with serveral pages i like.
when i try with the textbox:
<br />
private void btnEnter_Click(object sender, EventArgs e)<br />
{<br />
wb1.Navigate(new Uri(txtbox1.TextChanged.ToString()));<br />
}<br />
'The solution is proply easy tough i'm just an beginner
|
|
|
|
|
i have used the Image Processing Lab tool which was created by Andrew Kirillov...
I have one doubt.. how can use colorfiltering.cs file as a main one(separate project's main file).
but i should watch the changes in image in preview window while clicking tha redslider or blue slider or green slider which is in
colorfiltering form design..
|
|
|
|
|
How do I wake a sleeping thread when Thread.Resume is obsolete?
Som
|
|
|
|
|
Make the thread call Monitor.Wait() on a lock variable, then have the waking logic call Monitor.Pulse() on the same lock variable.
MSDN documentation: http://msdn2.microsoft.com/en-us/library/system.threading.monitor.aspx[^]
Example:
<br />
class Threaded<br />
{<br />
private object myLock = new object();<br />
<br />
private void GoToSleep()<br />
{<br />
lock(myLock)<br />
{<br />
Monitor.Wait(myLock);<br />
}<br />
}<br />
<br />
public void WakeUp()<br />
{<br />
lock(myLock)<br />
{<br />
Monitor.Pulse(myLock);<br />
}<br />
}<br />
}<br />
|
|
|
|
|
I am developing an windows application in which i have to calculate check digit...
For Example:
Data to be encoded is "21435".
encode: 2 1 4 3 5
Weighting: 5 4 3 2 1
-----------------------------------
Totals: 10 4 12 6 5
-----------------------------------
Then add them: 10 + 4 + 12 + 6 + 5 = 37
Next divide the total by 11 and get the remainder which is 37/11 = 3 remainder 4. The remainder is the check character.
To type encoding the data 21435 that can be scanned, print (214354).
How can i do this check digit calculation on every keypress event of textbox.......
Help me in getting solution.....................
|
|
|
|
|
So you want us to code an application in stead of trying yourself and then ask for hint if you really can't figure out what's wrong?
Maybe you should give it a shot...
|
|
|
|
|
Hi All,
I am working on FTP uitility using C#. I have build a class for that using C#. But while uploading the file on FTP i am unable to upload whole file on the FTP. Only part of that file is uploaded. I have used the following code to upload the file.
--------------------------------------------------------------------------
public void UploadData(string FTPUri, string FilePath, string FileName, string UserName, string Password)
{
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(FTPUri+FileName);
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(UserName, Password);
StreamReader ReadStream = new StreamReader(FilePath);
string ftpResponse = ReadStream.ReadToEnd();
ReadStream.Close();
reqFTP.ContentLength = ftpResponse.Length;
StreamWriter ftpStream = new StreamWriter(reqFTP.GetRequestStream());
ftpStream.WriteLine(ftpResponse);
ftpStream.Close();
ftpStream.Close();
}
--------------------------------------------------------------------------
Here i am able to upload only part of that file. Can anybody tell me what is the problem?
Thanking you.
Pravin
|
|
|
|
|
for getting full data without error use binary reader for uploading
like this
//FtpWebReq.Credentials = new NetworkCredential(userId, Password);
// FtpWebReq.Method = WebRequestMethods.Ftp.UploadFile;
//FtpWebReq.KeepAlive = false;
// FtpWebReq.UseBinary = true;
//FtpWebReq.ContentLength = FINFO.Length;
FileStream fsSource = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader binReader = new BinaryReader(fsSource);
Stream strm=null;
byte[] byteRead;
binReader.BaseStream.Seek(0, SeekOrigin.Begin);
long pos = 0, fLen = 0;
int buffLength = 2048;
int readSize = buffLength;
fLen = FINFO.Length;
try
{
strm = FtpWebReq.GetRequestStream();
while (binReader.BaseStream.Position < fLen)
{
pos = binReader.BaseStream.Position;
if (fLen - pos < buffLength)
readSize = (int)(fLen - pos);
byteRead = binReader.ReadBytes(readSize);
strm.Write(byteRead, 0, readSize);
}
binReader.Close();
strm.Close();
fsSource.Close();
}
|
|
|
|
|
I have developed a Windows Application which embeds "WebBrowser" Control. by default i have loaded one aspx page (which contains one server side button) into the browser. I want to invoke a Click method of this button (not manually) and pass arguments to the button click event. I have used the below code to pass arguments:
HtmlDocument doc = webBrowser1.Document;
HtmlElement btnTemp = doc.GetElementById("btnSubmit");
Object[] args = { "data1", "data2" };
btnTemp.InvokeMember("Click", args);
but i was not able to get these values in my aspx page.
i have also tried the below code:
Object[] args = { "data1", "data2" };
doc.InvokeScript("__doPostBack('btnSubmit',args)");
here is the code for my aspx page:
protected void btnSubmit_Click(object sender, EventArgs e)
{
Object[] args = new Object[] { e };
if (args != null)
Response.Write(args[0].ToString());
}
Can anyone can help me out how to get these values from my aspx page.
|
|
|
|
|
hi
i have to add the gif file into to datagrid.
i was very new to vc++ dotnet application. i tried to load gif file like bitmap file, it display the image not the action in the file.
how do i import gif file into datagrid??
thanks in adv
shivapalanirajan k.
iam a software engineer working for varisis technologies bangalore
|
|
|
|
|
I'm looking to develop a c# basic wireless remote control with an input screen that sends and receives signals to and from a pc. For a simple example of what I mean, click here.
I've been a c# software developer for 5 years now however I've never delved into the realm of hardware and electronics. Does anyone know of any books or online tutorials I can reference to point me in the right direction towards building something like this?
Thanks.
-Goalie35
|
|
|
|
|
... and I'm not afraid to admit. I thought I understood how they work but I guess I was wrong. So can you tell me if my understanding is correct.
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
s.Bind(new IPEndPoint(IPAddress.Parse("192.168.1.3"), 37));<br />
I don't have a problem with that, I understand protocols.
s.Listen(6); This means that the socket lets 6 clients connect to this socket to establish a connection. This socket isn't actually used to send/receive data (except under the surface).
This is the OnAccept Callback:
<br />
public void Accept(IAsyncResult ar)<br />
{<br />
Socket new_socket = s.EndAccept(ar);<br />
<br />
s.BeginAccept(new AsyncCallback(Accept), s);<br />
}<br />
s.EndAccept (ar) returns a new socket which you would use as a connection between host and client. new_socket and s are two seperate sockets. s.BeginAccept(new AsyncCallback(Accept), s) then tells the socket to begin accepting a new client. Now when I want to disconnect the host would do:
new_socket.BeginDisconnect(false, new AsyncCallback(OnDisconnect), s);
But I don't know what to do in the callback. I know there is Shutdown and Disconnect but I don't know where and on which end to do this.
Any helps would be greatly appreciated.
|
|
|
|
|
Hi,
Was wondering if anyone could recommend useful objects that could be used to programmatically compare two files/strings visually using dot net. {i.e.?? Using two grid controls that move in sync with each other?? - if possible}
Looking for useful places to look objects that could implement something similar to windiff/winmerge functionality... Highlighting differences quickly.
Just wondering where to start and if there are Addins etc that could programmatically do this..
If anyone has any information that would be great.
Regards
di
|
|
|
|
|
Hi,
I am getting the below error and am very confused. Firstly, the error is telling me i cant convert an object into the same object, WHAT?!
Object of type 'ConceptualGraph.Edge.IEdge[]' cannot be converted to type 'ConceptualGraph.Edge.IEdge[]'.
I get the error when trying to view a form in VS design mode which has a control on it. The only instance of an Edge[] is a generic List of IEdges i have in the control which just adds a new item to it or removes it.
Any ideas whats going off?
Regards,
Gareth.
|
|
|
|
|
A wild guess is that the Designer is interfacing with your custom controls IEdge member in some default way that it doesn't support like returning an Array. You probably have to provide an interface the Designer can use or maybe just make it private so the Designer ignores it, that all depends on your intended use of the IEdge List.
No way to be sure from what you posted but something in that general area.
led mike
|
|
|
|
|
I need some help. I can't seem to get my onclick event to fire when I render my buttons using ".RenderControl". Can somebody tell me what I need to do to get this to work. Thanks
<br />
public override void Render(HtmlTextWriter writer)<br />
{<br />
LoadSearchLibraryTitle(libraryID,writer);<br />
LoadSearchFields(libraryID,writer); <br />
}<br />
<br />
protected void LoadSearchFields (int libraryID, HtmlTextWriter htmlWriter)<br />
{ <br />
int fieldCounter = 0;<br />
<br />
SPFieldCollection listFieldCollection = listCaml.GetPropertiesOfDocumentLibrary(libraryID);<br />
<br />
htmlWriter.Write(@"<div style=""text-align:left"">");<br />
htmlWriter.WriteBreak();<br />
htmlWriter.Write("<table width='100%'>");<br />
htmlWriter.WriteBreak();<br />
htmlWriter.Write("<tr>");<br />
htmlWriter.WriteBreak();<br />
<br />
foreach (SPField listField in listFieldCollection)<br />
{<br />
if (!listCaml.IsHiddenField(listField.InternalName, ListGlobals.hiddenLibrarySearchField))<br />
{ <br />
htmlWriter.Write(@"<td style=""width: 20%; text-align:right;"">");<br />
<br />
Label label = new Label();<br />
label.Text = listField.Title + ":";<br />
<br />
label.RenderControl(htmlWriter);<br />
htmlWriter.Write("</td>");<br />
<br />
htmlWriter.Write("<td>");<br />
TextBox textBox = new TextBox(); <br />
textBox.MaxLength = Convert.ToInt16(listField.DisplaySize);<br />
textBox.ID = listField.InternalName;<br />
textBox.Text = listField.InternalName;<br />
<br />
<br />
<br />
textBox.RenderControl(htmlWriter); <br />
htmlWriter.Write("</td>");<br />
<br />
fieldCounter++;<br />
<br />
if (listFieldCollection.Count > 10)<br />
{<br />
if (fieldCounter == 2)<br />
{<br />
htmlWriter.Write("</tr>");<br />
htmlWriter.Write("<tr>");<br />
fieldCounter = 0;<br />
}<br />
}<br />
else<br />
{<br />
htmlWriter.Write("</tr>");<br />
}<br />
} <br />
}<br />
<br />
htmlWriter.Write("<tr>");<br />
htmlWriter.Write(@"<td style=""width: 20%; text-align:right;"">");<br />
htmlWriter.Write("</td>");<br />
htmlWriter.Write("<td>");<br />
<br />
LoadSearchButtons(htmlWriter);<br />
<br />
htmlWriter.Write("</td>");<br />
htmlWriter.Write("</tr>");<br />
<br />
htmlWriter.Write("</table>");<br />
htmlWriter.Write("</div>"); <br />
}<br />
<br />
protected void LoadSearchButtons(HtmlTextWriter htmlWriter)<br />
{<br />
searchButton = new Button();<br />
searchButton.Text = "Search";<br />
searchButton.RenderControl(htmlWriter);<br />
<br />
htmlWriter.Write(" ");<br />
<br />
resetButton = new Button();<br />
resetButton.Text = "Reset"; <br />
<br />
<br />
this.searchButton.Click += new EventHandler(searchButton_Click); <br />
this.resetButton.Click += new EventHandler(resetButton_Click);<br />
this.Controls.Add(resetButton);<br />
resetButton.RenderControl(htmlWriter);<br />
<br />
}<br />
<br />
protected void resetButton_Click(object sender, System.EventArgs e)* This won't fire when I us RenderControl.<br />
{ <br />
foreach (Control controls in this.Controls)<br />
{ <br />
if (controls is TextBox)<br />
{<br />
TextBox textBox = (TextBox)controls;<br />
textBox.Text = "";<br />
} <br />
}<br />
}<br />
<br />
protected void searchButton_Click(object sender, System.EventArgs e)* This won't fire when I us RenderControl.<br />
<br />
{ <br />
Server.Transfer(@"/LibrarySearch/ProcessingSearch.aspx");<br />
} <br />
<br />
<br />
<br />
<br />
|
|
|
|
|
Postback events are matched to their corresponding control and handler after Load and before LoadComplete . In order for your control to receive an event, it must be created, placed in the control tree (in the same naming container hierarchy), and have the event handler registered by the end of the Load portion of the page life cycle. Since your button does not get created until the page is in its Render state, it will never receive an event.
Hope that helps.
PS- You may want to consider posting these types of questions in the ASP.NET forum in the future.
--Jesse "... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
That was my issue.. when I move the control.add out of the render method it works.
thanks alot.
|
|
|
|
|
My pleasure. Glad it helped.
--Jesse "... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
Populating one my WinForms submenu requires database access over internet.
So it is better to populate it at runtime when in may become visible.
For this I use designer generated code in form constructor:
this.openToolStripMenuItem.DropDownOpening += new <br />
System.EventHandler(this.openToolStripMenuItem_DropDownOpening);
Initially menu does not contain any items.
When I move mouse to aparent menu item all is OK: DropDownOpening event
handler fills this menu with items.
However when I use keyboard keys to move to parent item, this event does not
fire: selection triange does not appear and it is not possible to open
submenu. I tried to use
this.openToolStripMenuItem.CanSelect = true; but got compile error CanSelect being is read only.
How to populate submenu when parent menu item is activated using keyboard ?
Andrus.
Andrus
|
|
|
|
|
Hi Andrus,
I've just taken a look at some code of mine that populates a submenu with a list of available COM ports and I think you have the drop down opening handler attached to the wrong menu item.
You want the selection triangle to appear when you activate the parent of the openToolStripMenuItem which is probably fileToolStripMenuItem. If you build your submenu when the fileToolStripMenuItem drops down it should all start working properly.
Alan.
|
|
|
|
|
Thank you.
I have 3-level menu structure
File
Open company
Company1
Company2
....
Companyn
I want that:
1. Selection triangle for "Open Company" is shown always.
2. Dynamic list Company1 .. Companyn is built only when I move focus to "Open company" item.
Issues:
1. I do'nt know how to enable selection triange initially in "Open company" menu when its list is empty.
2. When I highlight "Open company" menu item using keybord arrows, dynamic list is not populated.
Your suggestion to populate in file menu works but in this case menu is populated always when File menu is opened.
I need that menu is populated only when
In this case owever the dropdown is populated only When "Open Company" is selected from keyboard (selection from mouse works).
Andrus.
Andrus
|
|
|
|
|
Andrus,
I’ve been experimenting with my code to see if I could get the action you desire.
Clearly if you want to see a selection triangle then a submenu must be present. Why not replace a dummy submenu item at run time with your desired menu. Example code from my own application as follows.
private void openToolStripMenuItem_DropDownOpening(object sender, EventArgs e) {
dummyItem = openToolStripMenuItem.DropDownItems[0];
openToolStripMenuItem.DropDownItems.Clear();
ToolStripMenuItem comPortMenuItem;
String[] ports;
app.GetPortNames(out ports);
foreach (String port in ports) {
comPortMenuItem = new ToolStripMenuItem();
comPortMenuItem.Click += new EventHandler(comPortMenuItem_Click);
comPortMenuItem.DisplayStyle = ToolStripItemDisplayStyle.Text;
comPortMenuItem.Size = new System.Drawing.Size(152, 22);
comPortMenuItem.Text = port;
openToolStripMenuItem.DropDownItems.Add(comPortMenuItem);
}
}
private void openToolStripMenuItem_DropDownClosed(object sender, EventArgs e) {
openToolStripMenuItem.DropDownItems.Clear();
openToolStripMenuItem.DropDownItems.Add(dummyItem);
}
It's not very neat but it does work for both mouse and keyboard.
Alan.
|
|
|
|
|
I am creating a form where a user will fill out the form submit and will be sent as an e-mail. By using the asp:FileUpload will be able to send an attachment. I am using the MailMessage class to construct the e-mail and have it sent to a designated e-mail address. Where I am having troubles getting my head around is how to manage the attachments. The site itself is hosted off-site and I do not have a lot of space so the attachment needs to come directly to the building, or be held in a temp folder and be deleted after sending. I tried the following.
if (this.fiupDesign.HasFile)
{
filePath = Server.MapPath("~/App_Support/TempStorage");
filePath = Path.Combine(filePath, Path.GetFileName(this.fiupDesign.FileName));
this.fiupDesign.SaveAs(filePath);
fiupDesign.PostedFile.InputStream.Close();
} //end if
//Construct E-mail
mm = new MailMessage (this.txtEmail.Text, "email@email.com");
mm.IsBodyHtml = false;
mm.Subject = string.Format("Design - {0}", this.txtPatternName.Text);
mm.Body = sbTemplate.ToString();
mm.Attachments.Add(new Attachment(filePath));
sc = new SmtpClient("localhost");
sc.UseDefaultCredentials = true;
sc.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
sc.Send(mm);
/* Clean up temp file */
if (File.Exists(filePath))
File.Delete(filePath);
The problem here is that my cleanup of the temp file tries to delete the attachments to quickly and before they are sent so it throws an error saying "file is in use by another process." How would you of gone about doing this? Any help here would be fantastic. Even if it is an entirely different direction because this above isn't working.
Thank you for your help!
|
|
|
|
|
Wow. Don't write the file to disk just to turn around and read it and then delete it. Jeez dude.
Try using the Documentation for all the classes you are using and you will see that you can use the incoming stream to create the attachment without writing the file to disk.
led mike
|
|
|
|