|
I mean web application forms
post it somewhere = somewhere that is specified in action attribute of form
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
I don't think it is actually possible to post a web form to a web server using a WebForm. WebForms derive from System.Web.UI.Page and are meant to be sent to a web browser and not a web server. This is the job of a browser that you would like to do programatically as I understand? If yes, you can use System.Net.WebRequest to create a web request, and specify post as the method to accomplish this.
|
|
|
|
|
Thank you! I will try it!
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
string str = "<nish type = home tcode='gx99'>";
string pattern = "type[^>]+(tcode='(?<code>[\\S]+)')?[^>]*>";
Regex reg = new Regex(pattern, RegexOptions.IgnoreCase);
Match m = reg.Match(str);
if(m.Success)
{
Console.WriteLine(m.Groups["code"].Value);
}
This fails, but if I change pattern to :-
string pattern = "type[^>]+(tcode='(?<code>[\\S]+)')[^>]*>";
It works. Why won't the previous one work? I need to put a ? there because in certain cases the tcode=blah attribute might not be present.
Any help is hugely appreciated.
Nish
|
|
|
|
|
By failed I meant that while it does enter the if block it prints out a blank as if the captured group could not be found
Nish
|
|
|
|
|
Nishant S wrote:
Any help is hugely appreciated.
What about this pattern:
string pattern = "type[^>]+(tcode='(?<code>[\\S]+)?')[^>]*>";
The ? if I remember correctly matches the character preceeding the ? zero or more times.
-Nick Parker
|
|
|
|
|
Hello Nick
string pattern = "type[^>]+(tcode='(?<code>[\\S]+)?')[^>]*>";
This won't work when there is no tcode attribute at all. I want the whole outter group (tcode='abc') to get captured as an optional group. Anyway see my new post where I've added a space to temporarily solve the issue. I hope there aren't any hidden problems with that one
Nish
|
|
|
|
|
Nishant S wrote:
This won't work when there is no tcode attribute at all.
Ah, gotcha, I'm a little Glad you have it working.
-Nick Parker
|
|
|
|
|
|
Okay. It needed a space.
The correct pattern to use is :-
string pattern = "type[^>]+ (tcode='(?<code>[\\S]+)')?[^>]*>";
I am still a little scared though as to whether even this might have some hidden issues.
Nish
|
|
|
|
|
thats correct - looks like you need a space when tcode is there, I would suggest you make the space part of the optional tcode bit...
string pattern = "type[^>]+( tcode='(?[\\S]+)')?[^>]*>";
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I have 20 textboxes. Lets say, they are txtbox1 to txtbox20
Now, I would like to check them one by one if their text is null.
If txtbox1.Text is null, i would stop checking the other textboxes right away. I can easily perform this using an if-else but, its not gonna be that readable. So I want to use a switch statement. The problem is, how?
Please help.
"To teach is to learn twice"
|
|
|
|
|
daljv wrote:
So I want to use a switch statement. The problem is, how?
Why not just do soomething like this:
ControlCollection col = (ControlCollection)this.Controls;
foreach(Control t in col)
{
if(t is TextBox)
{
if(t.Text != String.Empty)
{
break;
}
}
}
-Nick Parker
|
|
|
|
|
Nick Parker wrote:
ControlCollection col = (ControlCollection)this.Controls;foreach(Control t in col){ if(t is TextBox) { if(t.Text != String.Empty) { // Do something here. break; } }}
Hmmm...
I can't help myself....
1~ he wanted to stop as soon as one text box had no text (actually he mentioned only the first text box, but I'll assume it was an example).
Thus
<br />
if(t.Text == String.Empty) break;<br />
Also, why not keep your own collection of controls containing only the text boxes so that you would not have to parse through all of the controls in the form?
Actually, since they are all text boxes, make it a collection of text boxes...
So, when you add them to the form's Controls in your initializer, also add them to myBoxes;
then:
<br />
foreach(TextBox t in myBoxes)<br />
{<br />
if(t.Text == String.Empty) break;<br />
}<br />
HTH,
F.O.R.
|
|
|
|
|
Frank Olorin Rizzi wrote:
if(t.Text == String.Empty) break;
Woops, I guess I flip-flopped that. Ah well, I think he got the main idea which was important.
Frank Olorin Rizzi wrote:
Also, why not keep your own collection of controls containing only the text boxes so that you would not have to parse through all of the controls in the form?
Because then he would have to maintain that collection where as the Form already maintains a collection of all controls applied to it. This is more extensible and easier to maintain. Granted there are other ways to do this, they simple require more work and don't provide much more in the efficiency department.
-Nick Parker
|
|
|
|
|
Nick Parker wrote:
Because then he would have to maintain that collection where as the Form already maintains a collection of all controls applied to it. This is more extensible and easier to maintain. Granted there are other ways to do this, they simple require more work and don't provide much more in the efficiency department.
This argument lacks, if there are more text boxes in th esame form...
Roland Bär
|
|
|
|
|
Roland Bär wrote:
This argument lacks, if there are more text boxes in th esame form...
Show me an example please.
-Nick Parker
|
|
|
|
|
Sorry, not precice enough ...
if you have the 20 textboxes, that should be tested, and then also other textboxes in the same form, that should not be checked, it is better to have the 20 textboxes in an own collection. Like this you can iterate over your collection without checking if it is a textbox to be checked or not.
Hope it is clear what I mean.
greets
Roland
|
|
|
|
|
Roland Bär wrote:
if you have the 20 textboxes, that should be tested, and then also other textboxes in the same form, that should not be checked, it is better to have the 20 textboxes in an own collection. Like this you can iterate over your collection without checking if it is a textbox to be checked or not.
There are other ways around your problem, however my answer still identifies how to accomplish what he was asking for.
-Nick Parker
|
|
|
|
|
Nick Parker wrote:
Because then he would have to maintain that collection where as the Form already maintains a collection of all controls applied to it
hmm.. yes, I see what you mean.
...speaking of which, let me ask this:
If I picked the TextBox object that gets added to the Form's Controls collection (say it is named tBox1), and simply add it to my own collection (say an Hashtable) like so:
myTable.Add(myTable.Count, tBox1);
Wouldn't I be adding just a reference?
Thus the impact on the memory would be relatively small?
Or am I missing something here?
|
|
|
|
|
There are many ways in which you can tackle this, depending on the exact circumstances you should consider using a specific method. My method is rather abstract.
-Nick Parker
|
|
|
|
|
this won't work - t is TextBox, t would still be a Control which does not have a .Text field so use "as".
also why are you casting this.Controls? its a ControlCollection already...
foreach(Control t in this.Controls)<br />
{<br />
TextBox tb = t as TextBox;<br />
<br />
if(tb != null && tb.Text == String.Empty)<br />
{<br />
break;<br />
}<br />
}
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
this won't work
Yes, it will, try it.
Philip Fitzsimons wrote:
also why are you casting this.Controls? its a ControlCollection already...
Test your code, it will fail if you don't cast it, mine did, I previously wasn't casting it.
-Nick Parker
|
|
|
|
|
I can't see who it would work - it won't work on my computer...
"t" is a Control.
"t.Text" is not valid on a Control.
how does it compile?
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
how does it compile?
Drop my code onto a form, it works.
-Nick Parker
|
|
|
|