|
Create a static class with global var,
in you form 2, asign the value of text box to the var,
you can use the value anywhere you want by refrencing the class and the varibale.
hope this helps.
|
|
|
|
|
What do you intend to do with the test class? (choose better names like MyTestClass so you don't accidentally use reserved words)
You should create a public property in your MyTestClass for the strID. (Tip: type prop and hit tab twice). Create an instance of your MyTestClass in the form load of Form2 and then you can set the TextChanged event of txtTextBox1 to set the value of that property.
You might want to do some reading on object oriented programming. From what you have written it looks like you are used to procedural programming. Try this one C# Tutorial - An Object Oriented Approach to Programming[^]
|
|
|
|
|
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
test t1 = new test(); //Create an instance of test class.
t1.hello(textbox1.text);
}
}
public class test
{
string strID;
public string hello(string message)
{
strID= message; //here i am confused with my basic concept (can i assign value to strID from TextBox and if yes then how to get TextBox Value from form2 because I am making a new class here)
return strID;
}
}
}
jaypatel512
|
|
|
|
|
the question is not clear what exacly do u want to do, do you have two forms, or are u requesting the valu from the same form.
you can use a command button and put your code in the click event of the button.
hope this helps.
|
|
|
|
|
Hey guys,
I have implemented a
<input type = "file" runat ="server"/>
so that user can select files.
Also I would like to add a file prefix e.g. .txt, .csv or .cs
so that only these kinds of files will be allowed. I can't get this right.
I tried
<input id = "files" type = "file" accept = "text/csv, text/txt, text/cs" runat = "server"/>
and it won't work....
Anybody there with a little help
Please help
Morg
|
|
|
|
|
MorgSim wrote:
You can use ASP.net fileupload control, no need to use input type='file'.
MorgSim wrote:
What you can do is use validation control which will check the file extension, and validate it.
Hope this help.
|
|
|
|
|
And remember that regular expressions are case sensitive
(.*?)\.([cC][sS][vV]|[tT][xX][tT]|[cC][sS])$
|
|
|
|
|
Thanks you all guys that was helpful
|
|
|
|
|
Hy,
I have a requiremnet in wi=hcih i hav to get a file from the client server and place it in my local machine.
the file may be of any type
thanks in advance,
raghvendra Panda
|
|
|
|
|
With ASP.NET you will not be able to push the file, you must make it available for the user to download. Place a link to the file on your page.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You need to be more precise with your terminology. When you say "client" do you mean customer or do you mean person using the browser? Is your local machine hosting the web site?
My two best guesses of what you mean are
1) User on computer A (client) using his browser uploads to computer B (server hosting the site) which then sends to your computer C
OR
2)Some process on computer Q (the server) automatically sends a file to your computer P without you having to click to download
|
|
|
|
|
hai ,
iam experiencing a strange problem.
some of the setting have been changed in visiualstudio and suddenly every space is filled by (DOT).
for example the code looks as below shown.
.....public.int.pdate.(string.empname,int.salary,int.dep)
.........{
.SqlConnection.conn=new.SqlConnection(connstr);
conn.Open();
..try
{
string.st.=."update.INTO.Employee..( EmpName,Salary,Dep).".+"VALUES.(empname,salary,dep)";
every page it looks the same and even in javascript pages also..
any one who knows solution please message here..
thanks in advance
|
|
|
|
|
Ctrl+R+W
me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
|
Hello,
I am working on a school result processing project. I have one checkedlist control which have 3 options:(To choose paper code)
All
First
Second
to select the paper code option. All stands for all papers i.e. paper1 and paper2; while if any of other than "All" option checked by user; the respective action should be taken place. Suppose, user checked on option First, then all records whose papercode <> 1; will be deleted by command.ExecuteNonQuery() and if user checked on Second, then all records whose papercode <> 2; will be deleted by command.ExecuteNonQuery(). If user checked on All or any of First/Second; no action is needed; because All option means no action required.
Kindly help to code this requirement or let me know, if i am not clear to explain my question.
Thank and Regards
Girish Sharma
|
|
|
|
|
Your problem is not very clear.Can you explain a bit?
What I understand, you need to delete the record if user selects first or second and dont need to do anything if user selects all. if yes then have check at serverside and take the action accordingly.
|
|
|
|
|
Hi Brij,
Thanks for your reply and time given to my problem. Let me once again clear it more:
If user selected "All" option with/without First/Second option then no action is required.
If user selected First only then
deleted those records whose papercode <> 1
Endif
If user selected Second only then
deleted those records whose papercode <> 2
Endif
If user selected First and Second
No Action required
Endif
If user selected All+First+Second
No action required
Endif
Means, only action required on selection of single "First" or "Second" option and wish to perfrom some delete operation on table.
Its vb.net 2005 project please.
Regards
Girish Sharma
|
|
|
|
|
I donno much about vb.net, but are you not able to check which all checkboxes checked at serverside?
|
|
|
|
|
hi, iam using asp.net2.0 with c#
in my gridview 1st column is checkbox control in template fileds
and iam using paging also. when user clicks the button ,all selected no of check boxes data has to be send in mail
can you give example which helps me
|
|
|
|
|
So what problem you are facing,on button click, iterate throgh the gridview rows and check the checkbox status and accordingly send the mail to all checked.
if facing any problem in sending mail then have a look
|
|
|
|
|
while iterating how i have to take that data and print as it is
can you give example which helps me
|
|
|
|
|
See, you need to prepare the format of mail as you already have all the data or you can read all the data from grid.So create mail body accordinly and send mail. and if you want the same html as grid then you can get the html as
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter textWriter = new HtmlTextWriter(sw);
grid1.RenderControl(textWriter);
string gridHTML= sb.ToString();
Now you have the html of grid as gridHTML and now use as you need.
|
|
|
|
|
hello all,
I have made a project in asp.net, in which there is need to have countDown timer using javascript .So, I have made a code for it. But it resets after very postback or you can say on every page refresh, Timer reset .
There must be static timer that should display some minutes and secs to remain .
Could anyone know the code of reverse timer for minutes and seconds that should not reset after page refresh.???
Thanks in advance
|
|
|
|
|
You must save the timer count on postback
and restore timer count when page reloads,
Use hidden field or cookie or the query
string to store the timer count value.
|
|
|
|
|
When the page loads, it checks for a particular cookie. If it is not found, it is the first time the page has been loaded: figure out the time to which you are counting down and set the cookie. If it is found, load it and start counting down again.
An alternative would be to store the time server-side -- the session object might be a good choice. If Session("Deadline") does not exist, the page is being generated for the first time; if it does, it contains the time. Use it to set a hidden field in the code that your Javascript will reference.
There are problems with either approach, but they should usually work.
|
|
|
|