Reputation: 71
I am new on mvc programming. I have two labels, two textboxes and one button and I have to use devexpress tools. It is like login form. I want to call an actionresult from a controller class when I click the button. How can I do that if it is possible?
That's my button
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Giriş" OnClick="ASPxButton1_Click" Theme="Moderno" EnableTheming="True"></dx:ASPxButton>
and that's my button click event
<script runat="server">
protected void ASPxButton1_Click(object sender, EventArgs e)
{
}
</script>
and these are in Index.aspx page.
Upvotes: 0
Views: 5571
Reputation: 11480
I'm not entirely sure what your asking, but I'll attempt to clarify.
// Model View Controller:
<form action="/Home/Validate" method="post">
<input type="text" name="username" required />
<input type="text" name="password" required />
<input type="submit" value="Submit" />
</form>
That would be in your code, then you hit the button which will submit your form and point to your Validate Controller
. Which would look like:
public ActionResult Validate(string username, string password)
{
// Do Stuff, then call your next view and pass model.
return RedirectToAction("Account");
}
Important: In Model View Controller you don't call button clicks, you call Controllers. So you would point your destination to a Controller method (example):
<a href="/Home/Validate">Validate</a>
<input type="button" onclick="/Home/Validate" />
Your code is from the realm of an Web-Forms, if it is all server side code without custom JavaScript then you may be able to simply do:
<asp:UpdatePanel id="updAccount" runat="server">
<ContentTemplate>
// Your button, textbox for Submit (Alleviates Postback).
</ContentTemplate>
</asp:UpdatePanel>
That would be the simpler of the two Web-Forms approach. However, you could indeed use jQuery or JavaScript to accomplish this as well.
Upvotes: 1