|
|
Hi
I have a strange problem.
There's a MdiForm that has a menu item on its main menu.
Here's its click event handler
<br />
private void ShowMyForm(object sender,EventArgs e)<br />
{<br />
MyForm frm=new MyForm();<br />
frm.MdiParent=this;<br />
frm.Show();<br />
}<br />
and it's working fine.
But when I want to replace this code with a command pattern , MyForm won't be added as a child of main form
Here's what I did:
<br />
public class ShowMyFormCommand:ICommand<br />
{<br />
Form mdiParent;<br />
public ShowMyFormCommand(Form mdiParent)<br />
{<br />
this.mdiParent=mdiParent;<br />
}<br />
public void Do()<br />
{<br />
MyForm frm=new MyForm();<br />
frm.MdiParent=this.mdiParent;<br />
frm.Show();<br />
}<br />
}<br />
then I replaced the code in event handler with this
<br />
private void ShowMyForm(object sender,EventArgs e)<br />
{<br />
new ShowMyFormCommand(this).Do();<br />
}<br />
Can you tell me what's wrong ?
Thanks
Nima H
|
|
|
|
|
Hello
Maybe I wasn't following the code correctly but in this line:
this.mdiParent=mdiParent
If the class ShowMyFormCommand is a memebr class of your form then this keyword will reference to your main form. Your main form doesn't have a MDIParent and thats why it should be null. So in the Do method
frm.MdiParent=this.mdiParent;
Your new form doesn't get an MDIParent because this.MDIParent should be null. Try to debug through the code to see if it's null or not.
Regards
|
|
|
|
|
Hi
Thank you for your kind reply.
I will debug my app.
|
|
|
|
|
Hi all,
Would someone please show me an example of how to use the post request in c#. I want to run a URL but when i use the following...
string Argu = "http://sms.co.za:5567/eapi/sub/send_sms/2/2.0?username=Whatever&password=BlahBlah&message=" + Convert.ToString(Message) + "&msisdn=" + Convert.ToString(CellNo);<br />
HttpWebRequest Request;<br />
StreamReader ResponseReader;<br />
Request = ((HttpWebRequest)(WebRequest.Create(Argu)));<br />
ResponseReader = new StreamReader(Request.GetResponse().GetResponseStream());
i get an error that says that the URI is to long...
Then i went to look for anything like this on the sms providers help files... i found this: "Please remember to URL-encode all parameters passed! Don't reinvent the wheel - rather use one of the countless libraries available. GET requests are allowed, but we strongly recommend using POST requests, especially if submitting a message to a large number of recipients (there can be limits on the size of GET requests)."
What does this mean...?
How do i use the POST request to run my variable that contains the URL: "Argu" without getting the error of the uri being too long.
Please help.
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Basically, you create a web request with just the URL (no variables)
string Argu = "http://sms.co.za:5567/eapi/sub/send_sms/2/2.0"<br />
HttpWebRequest Request = ((HttpWebRequest)(WebRequest.Create(Argu)));
You tell it to use post
Request.Method = "POST";
Then you add each of your variables as header items
Request.Headers.Add("username","whatever");<br />
Request.Headers.Add("password","blah");<br />
Request.Headers.Add("message","hello world");<br />
Thats all typed by hand, so there might be some mistakes - should give you the idea though.
|
|
|
|
|
Would this:
Salon.Library.SystemDefault sysdef = new SystemDefault();<br />
sysdef.LoadData();<br />
ASCIIEncoding encoding = new ASCIIEncoding();<br />
string postData = "username=Whatever&password=BlahBlah&source_id=" + Convert.ToString(sysdef.ID) + "&message=" + Message + "&msisdn=" + CellNo;<br />
byte[] data = encoding.GetBytes(postData);<br />
<br />
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://bulksms.2way.co.za:5567/eapi/submission/send_sms/2/2.0?");<br />
myRequest.Method = "POST";<br />
myRequest.ContentType = "application/x-www-form-urlencoded";<br />
myRequest.ContentLength = data.Length;<br />
Stream newStream = myRequest.GetRequestStream();<br />
<br />
newStream.Write(data,0,data.Length);<br />
newStream.Close();
Am i doing this correctly? I saw this in an example on the net...
is this the same as the top part but the top part is the post part?
string Argu = "http://bulksms.2way.co.za:5567/eapi/submission/send_sms/2/2.0?username=Whatever&password=BlahBlah&source_id=" + Convert.ToString(sysdef.ID) +"&message=" + Convert.ToString(Message) + "&msisdn=" + Convert.ToString(CellNo);<br />
HttpWebRequest Request;<br />
StreamReader ResponseReader;<br />
Request = ((HttpWebRequest)(WebRequest.Create(Argu)));<br />
ResponseReader = new StreamReader(Request.GetResponse().GetResponseStream());
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Okay i got it to work with this code...
Salon.Library.SystemDefault sysdef = new SystemDefault();<br />
sysdef.LoadData();<br />
ASCIIEncoding encoding = new ASCIIEncoding();<br />
string postData = "username=Whatever&password=BlahBlah&source_id=" + Convert.ToString(sysdef.ID) + "&message=" + Message + "&msisdn=" + CellNo;<br />
byte[] data = encoding.GetBytes(postData);<br />
<br />
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://bulksms.2way.co.za:5567/eapi/submission/send_sms/2/2.0?");<br />
myRequest.Method = "POST";<br />
myRequest.ContentType = "application/x-www-form-urlencoded";<br />
myRequest.ContentLength = data.Length;<br />
Stream newStream = myRequest.GetRequestStream();<br />
<br />
newStream.Write(data,0,data.Length);<br />
newStream.Close();
But how do i know when an error occurs with this example...
Will this allow me to use more than 2083 caracters in the uri or will it give me an error like with the previous attempt to send the uri request with the get and not the POST. How can i test this, this method does not bring back errors...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Good morning to all. Could anyone please tell me how to syncronize two richtextbox scroll positions? I'm now already on dangerous caffiene levels and running out of ideas.
I'm overriding WndProc to catch the Scroll event and I'm using GetScrollInfo() to
return position data and-so-forth but I'm having no luck with setting or syncronizing the two richtextboxe scrollbars. Please help.
An example that i got of the net shows me how to move the scrollbar up and down but not ultimately to a specific position.
Regards and many thanx
|
|
|
|
|
Hello
You can change the caret position in the second RichTextBox accroding to the first scrollposition, then use RichTextBox.ScrollToCaret() method to scroll accrodingly.
Regards
|
|
|
|
|
Hello
how to set windows default sound card devices in c#.NET
Yogesh_T
|
|
|
|
|
How can i assign a string to DataSet?
sAqIb
|
|
|
|
|
Why you want to store into a dataset?
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
I have a problem. I have a dataset contains 8 tables. Each table contains 25,000-30,000 records. I want to insert all the records at a time. There is no primary key or foreign key constarints or no conditions to check. Just dumping to database. That's all. For that I used the below code. But no insertion is happening. Can anybody help please?
SqlDataAdapter PEOQCAdap=new SqlDataAdapter();
SqlCommand inscommand=new SqlCommand();
inscommand.Connection=SqlCon;
inscommand.CommandType=CommandType.StoredProcedure;
inscommand.CommandText="INSERT_NOISSUELEVEL";
inscommand.Parameters.Clear();
inscommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@VALUE1",System.Data.SqlDbType.VarChar,50,"VALUE"));
inscommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ASTNDA",System.Data.SqlDbType.BigInt,8,"AST_FOR_NDA_ID"));
inscommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ANALAYST",System.Data.SqlDbType.VarChar,50,"CREATE_BY"));
inscommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CREATEDATE",System.Data.SqlDbType.NVarChar,50,"CREATE_DATE"));
inscommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NDAID",System.Data.SqlDbType.BigInt,8,"NDA_ID"));
inscommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@COMPANY",System.Data.SqlDbType.VarChar,50,"COMPANY_NAME_AT_OFFER"));
PEOQCAdap.InsertCommand=inscommand;
PEOQCAdap.Update(ds.Tables[0]);
Any sort of help is great!!!
Thanks
Raja Raman S
Reuters India Pvt.Ltd.
Bangalore
|
|
|
|
|
hi
could someone please tell me how to read .resx file from the code.
note : in a web form
thank you all
Tamimi - Code
|
|
|
|
|
Resource files are Xml files, so you could use XmlTextReader or XmlDocument types.
If you want to access the information without dealing with Xml take a look at the ResourceManager class.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
|
Hi, I want create a Label with transparent Color as "Color.FromArgb(40, 0, 0, 255)"
how can I do?
Please help me
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
Hello
You'd have to inherit your own class from class Label, and in your class call
SetStyle(ControlStyles.SupportTransparentBackColor, true);
Then change the BackColor as you like.
Regards
|
|
|
|
|
Hi,
Does any body know how to host multiple server channels in an exe, or is it possible to do that... I have a windows service and I need at least 2 server channels when I make a second call to TcpServerChannel constructor then and exception comes that the tcp channel is already registered...
Can any body help...
Thanks in advance...
Regards.
-- modified at 3:18 Wednesday 27th September, 2006
|
|
|
|
|
I have a webservice through which i have to access a specific folder and then hae to retrieve the list of some specific files (file name, date created, last modified) from that folder. I have done it successfully. Now i want to access this method of webservice in my c# application. I am confused to access this method. I am not sure what to return and how to return values from that method of webservice. I want to use file name, date created, and last modified date from that webservice to populate ListView in the C# application. can anybody help me by telling me what should be the return value of that webmethod of webservice?
Regards
sAqIb
|
|
|
|
|
Create a simple class that encapsulates the information and return an array og this class.
public class Info
{
public string Name;
public DateTime Created;
public DateTime LastModified;
}
[WebMethod]
public Info[] GetFiles()
{
return new Info[2];
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hai,
I am eswar i am trying to read the items from the list box here in list box we can select multiple items how to read these multiple items from the listbox can any body help in this situation.
regards,
Eswar.
|
|
|
|
|
code> private void Form1_Load(object sender, System.EventArgs e)
{
for(int i=0;i<10;i++)
{
listBox1.Items.Add("this is" + i.ToString());
}
listBox1.SelectionMode = SelectionMode.MultiExtended;
}
private void button1_Click(object sender, System.EventArgs e)
{
for(int i=0;i<listbox1.selecteditems.count;i++)
{
="" messagebox.show(listbox1.selecteditems[i].tostring());
="" }
="" }<="" code="">
|
|
|
|