|
|
I found the solution ( this[^] message explains more)
Thanks for your reply!
|
|
|
|
|
Hi ,
I have a search on my form[say,parent form]. When I click on search button ,I want to display the results in a modal window and return the selection back to parent form and populate controls with the returned data.
Any suggestions would be appreciated.
Thanks
|
|
|
|
|
This[^] shows how to do what you want. It uses a string, but you can pass any type you wish.
|
|
|
|
|
Do it with events. When the data is returned, post a custom event, and have the first form hook that event and perform the appropriate processing.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
As an alternative, you could create a static class. Just make a form with a textbox, and a button with "DialogResult" set to "OK", and a static wrapper...
public partial class Input : Form
{
public Input()
{
InitializeComponent();
}
public string StringValue
{
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
}
public static class InputBox
{
private static Input _input = new Input();
public static DialogResult ShowDialog(string caption, ref string value)
{
_input.Text = caption;
_input.StringValue = value;
if (_input.ShowDialog() == DialogResult.OK)
{
value = _input.StringValue;
return DialogResult.OK;
}
return DialogResult.Cancel;
}
}
Then use it like this...
private void button1_Click(object sender, EventArgs e)
{
string x = "Some default text";
if (InputBox.ShowDialog("Test", ref x) == DialogResult.OK) MessageBox.Show(x);
}
|
|
|
|
|
That has to be one of the most inappropriate uses of static I have ever seen.
Why on earth would you do it that way, when a simple public property in your Input class (which you already have) does the same thing?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I assume you mean to do something like this?
private void button1_Click(object sender, EventArgs e)
{
Input inBox = new Input();
inBox.StringValue = "Some default text";
if (inBox.ShowDialog() == DialogResult.OK) MessageBox.Show(inBox.StringValue);
}
|
|
|
|
|
Yes. Either that way, or with a constructor requiring the header and default text.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
From what I was reading, it looked like he was asking a question similar to this one. Perhaps he wasn't, my mistake.
The purpose of the static class is to give it "MessageBox-like" usage; e.g., you don't have to use "new MessageBox() " to instantiate that dialog, you can simply call one of the "MessageBox.Show() " overloads.
Regardless, the code I listed above is not thread safe. Here would be a better version:
public partial class Input : Form
{
public Input()
{
InitializeComponent();
}
public Input(string caption, string defaultValue) : this()
{
this.Text = caption;
textBox1.Text = defaultValue;
}
public string StringValue
{
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
}
public static class InputBox
{
public static DialogResult ShowDialog(string caption, ref string value)
{
Input inForm = new Input(caption, value);
if (inForm.ShowDialog() == DialogResult.OK)
{
value = inForm.StringValue;
return DialogResult.OK;
}
return DialogResult.Cancel;
}
}
And a usage example (with threads):
private void button1_Click(object sender, EventArgs e)
{
new Thread(new ParameterizedThreadStart(doMessage)).Start("one");
new Thread(new ParameterizedThreadStart(doMessage)).Start("two");
}
private void doMessage(object msg)
{
string x = msg.ToString();
if (InputBox.ShowDialog("Test", ref x) == DialogResult.OK) MessageBox.Show(x);
}
|
|
|
|
|
All your static class is doing is moving the instantiation out of the original class, and making the input message harder to use.
It also depends on the (unknown) Input form to return "OK" or "Cancel" rather than "Yes", "No" or "Cancel".
Why make it static? If all you want to do is hide the instantiation, put it in s non-static method and you get exactly teh same result, but better contained. You could make that static if you really wanted to, but I wouldn't necessarily bother.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
i have store procedure which tooks 10 mints to execute so it will get time out in my application.
i think we can set Connection.Timeout in web config.
can any one tell me where to set that in web config??
|
|
|
|
|
Use <connectionstrings> in Web.Config like this
<connectionStrings>
<add name="TestConnectionString" connectionString="Data Source=Test_XXXX;Initial Catalog=DB_Name;Integrated Security=True; Connection Timeout=200;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Go through this link, You can get good idea about connection strings.
connectionstrings[^]
P.S: Check why that procedure taking two much time (10 minutes).
Happy Coding
Regards,
Eswar
|
|
|
|
|
Thanks for the swift reply..
like this means..how?? because i want syntax...where to add and ahta i have to add
i check link given by you...but it has nt mention any where....any thing related to time out
|
|
|
|
|
Mugdha_Aditya wrote: ike this means..how?? because i want syntax...where to add and ahta i have to add
For Web.Config concept See this http://msdn.microsoft.com/en-us/library/w7w4sb0w(v=VS.80).aspx[^]
Mugdha_Aditya wrote: i check link given by you...but it has nt mention any where....any thing related to time out
Link is only about connection strings with respect to different databases & different parameters.
Are you want sample syntax of web.config file?
|
|
|
|
|
i waant to add timeout hours in web config...
i want sample for tht... so i can add same thing in my web config for time out
|
|
|
|
|
10 minutes? Sounds more to me like you need to refactor/refine your stored procedure and schema a bit. I've written queries that take as long as three seconds, but never *minutes*. Believe me when I say the timeout is the least of your worries.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
ok..
but still how can i add time out time in webconfig
|
|
|
|
|
You can't. That timeout is for connecting to the database, not executing a command on it. See my other post for more info.
|
|
|
|
|
Ummm, I hate to rain on everyones parade here, but changing the timeout in the connection string doesn't work. That's the timeout for the CONNECTION to the database, not the timeout for executing a command on the database.
You're looking at CommandTimeout[^].
But, like JSOP said, if you've got a long running query like this, you're best option is to try and improve the query's performance first. Having done that, if still too long, run the query async so your code isn't blocked waiting 10 minutes for the query to return. Look at the Begin* methods of the SqlCommand object.
|
|
|
|
|
There are two type of timeout which we can use in asp.net-
SqlCommand.CommandTimeout = timeout limit for your SQL query. Means, how much time a (eg: SELECT, UPDATE) query can take for its execution. If it exceeds SqlCommand.CommandTimeout, then it stops execution. A command timeout error will occur.
SqlConnection.ConnectionTimeout = timeout limit for your connection. Means, how much time your connection object can try to connect. If it exceeds the specified time, it stops connecting. A connection timeout error will occur.
HELLO GUY
|
|
|
|
|
Hi developers
I am here to clear my serious doubt about an issue,that came in between my coding.I made a sticky note software in c#.net and it also has a user registration criteria.So in order to do that,that software asks for the username and organization name in a form,and the end user types his name and other details in the textbox and submits it.When user clicks submit,the form carries out the data to the web (opening in an explorer),and shows the name and other details in the web-page controls and stores it in a database.Actually how to do this?I need a quick solution.Please help me your answers dears!
varun
|
|
|
|
|
varun.g wrote: Actually how to do this?
That is your task. Although it is not exactly clear whether this is a Windows Forms or Web question.
varun.g wrote: I need a quick solution.
Try some research into your problem and come back here when you have a more specific question.
I must get a clever new signature for 2011.
|
|
|
|
|
Dear Richard
Thanks for your comments.BTW why don't you see the title "windows application contents available and save online".It clearly tells issue.I need to show the windows application contents in a web page and save that content directly to the web database.I need a wise solution please..
|
|
|
|