|
The user name and password that you are providing are not correct.
Perhaps you are using something completely different as user name and password? If the code that you are using differs from the code that you are showing, you should mention it. It's impossible for someone else to see an error in code that you don't show.
If the user name and password contains different characters, they may need to be url encoded:
strNewValue = "login_form_username=" + Server.UrlEncode("user") + "&login_form_password=" + Server.UrlEncode("haslo");
When a form is posted, the value of the button used to post the form is also included in the data. You might need to include the value for the button for the code to react to the posted data.
---
single minded; short sighted; long gone;
|
|
|
|
|
is the Server.UrlEncode part of some namespace ?? Bacause when I added it I get en error
Error 1 The name 'Server' does not exist in the current context
I've addes System.Web; but it didn't help
|
|
|
|
|
It's in the HttpServerUtility class, but that is only available if you have an ASP.NET application.
You can use the HttpUtility.UrlEncode method instead.
---
single minded; short sighted; long gone;
|
|
|
|
|
I've changed it as you suggested but nothing changed
|
|
|
|
|
There are two hidden fields in the form also. Aren't they needed?
---
single minded; short sighted; long gone;
|
|
|
|
|
I've added them as such
strNewValue = "login_form_username=" + HttpUtility.UrlEncode("user") + "&login_form_password=" + HttpUtility.UrlEncode("haslo") + "&from_module=" + HttpUtility.UrlEncode("home") + "&form_name=" + HttpUtility.UrlEncode("login");
and as such
... + "&from_module=home&form_name=login";
but with no result
|
|
|
|
|
Have you tried adding a value for the button, as I suggested earlier?
---
single minded; short sighted; long gone;
|
|
|
|
|
so right now the string value has grown to:
strNewValue = "login_form_username=" + HttpUtility.UrlEncode("user") + "&login_form_password=" + HttpUtility.UrlEncode("haslo") + "&loginBoxSubmit=" + HttpUtility.UrlEncode("Login") + "&from_module=" + HttpUtility.UrlEncode("home") + "&form_name=" + HttpUtility.UrlEncode("login");
but it didn't help
|
|
|
|
|
That looks right.
What message do you get when the login fails?
Does the login require cookies?
---
single minded; short sighted; long gone;
|
|
|
|
|
after checking there is only a PHPSESSIONID cookie from that website
|
|
|
|
|
What message do you get when the login fails?
---
single minded; short sighted; long gone;
|
|
|
|
|
I just get this site: http://login.americasarmy.com
|
|
|
|
|
When you try to log in but fail, there is a message displayed on the page. What message is displayed on the page that you get?
---
single minded; short sighted; long gone;
|
|
|
|
|
when the login fails when I try yo login through the website a just get the same page with "Invalid login." under the login form
when I do it from the c# app. I just get back to the login page with no message
|
|
|
|
|
That means that the site did not even recognise the post. It thinks that it's just a regular request.
Re-check everything that you send in the post, so that you have spelled (or misspelled) everything correctly.
---
single minded; short sighted; long gone;
|
|
|
|
|
already did that and additionally I copy&paste the field names from the website source code to my code
|
|
|
|
|
Hi All,
I have simple C# class that hold some FORM.
This form hold some USER CONTROL`s.
What i need to do ( and i don't know how to do it ) is to send events from the some of the user control to this simple C# class and the C# class will also send events to those user control.
How do i declare those event in the C# class ? and how i send it from/to those user control ?
I don't want to make some function that will call the Form function and from the form to call the user control function ... i just want to do it directly from the class to/from the user control.
Thanks for any help.
-- modified at 3:59 Tuesday 31st July, 2007
|
|
|
|
|
Yanshof wrote: How do i decline those event in the C# class
You mean how to do cancel those events? i.e. if you have an event called BeforeClick you want to be able to say "no cancel that action" so that the main click event is not fired?
|
|
|
|
|
Sorry, but one can't understand what you want.
Maybe you can post the code that isn't working?
Failure is not an option - it's built right in.
|
|
|
|
|
I'm very sorry -
You are right - i modify my message.
I mean how to declare.
|
|
|
|
|
|
Hello,
Yanshof wrote: is to send events from the some of the user control to this simple C#
Your UserControl should implement an event like this:
public event EventHandler SomethingChanged;
and fire it like this:
if (SomethingChanged!= null)
{
SomethingChanged(this, EventArgs.Empty);
}
Your class, (which holds the instance of the form where the usercontrols are on) should implement a method which returns a list of your UserControl:
private ArrayList GetAllUserControls(Control c, ArrayList allUserControls)
{
if(allUserControls == null)
{
allUserControls = new ArrayList();
}
if(c!=null)
{
if(c.Controls!=null)
{
foreach(Control actControl in c.Controls)
{
YourUserControl actYourControl = actControl as YourUserControl;
if(actYourControl!=null)
{
allUserControls.Add(actYourControl);
}
allUserControls= GetAllUserControls(actControl, allUserControls);
}
}
}
return allUserControls;
}
And call it like that:
ArrayList allUserControls = GetAllUserControls(yourForm, null);
Then you can register the Events.
I would recommend a method which does also the unregistering for your Dispose method.
private void EditEvent(ArrayList allUserControls, bool register)
{
foreach(object o in allUserControls)
{
YourUserControl actYourControl = o as YourUserControl;
if(actYourControl!=null)
{
if(register)
{
actYourControl.SomethingChanged+=new EventHandler(actYourControl_SomethingChanged);
}
else
{
actYourControl.SomethingChanged-=new EventHandler(actYourControl_SomethingChanged);
}
}
}
}
And call it like that (you have to pass the List of UserControls which you got from the GetAllUserControls method):
EditEvent(allUserControls, true);
and in the dispose method:
EditEvent(allUserControls, false);
To find the correct instance in the handler:
private void actYourControl_SomethingChanged(object sender, EventArgs e)
{
YourUserControl actYourControl = sender as YourUserControl;
if(actYourControl!=null)
{
}
}
Yanshof wrote: the C# class will also send events to those user control.
Here I would use a static event in the class.
Hope it helps!
-- modified at 5:21 Tuesday 31st July, 2007
All the best,
Martin
|
|
|
|
|
Can you please explain what do you meed in the line
"YourUserControl actYourControl = actControl as YourUserControl"
?
Thanks.
|
|
|
|
|
Yanshof wrote: YourUserControl actYourControl = actControl as YourUserControl
The 'as' operator tries to cast the Control instance "actControl" to an instance of YourUserControl.
If the cast is not working it will return 'null', an ddoes not throw an exception (like "(YourUserControl)actControl" would do)
All the best,
Martin
|
|
|
|
|
Sorry, there was an error in this line, changed it now!
All the best,
Martin
|
|
|
|