Hitno mi treba pomoc,
Kako se poziva neka metoda(akcija) koja se nalazi u nekom kontoleru iz view-a.
Imam kontorler:
Ovo mi je view,
Htio bih pozvati akciju Create iz kontolera klikom na dugme input?
Moze li mi ko reci kako da to uradim?
Kako se poziva neka metoda(akcija) koja se nalazi u nekom kontoleru iz view-a.
Imam kontorler:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Edit2011.Controllers
{
public class GalleryController : Controller
{
//
// GET: /GalleryControler/
public ActionResult Index()
{
return View();
}
public ActionResult Categories()
{
return View();
}
public ActionResult Overview()
{
return View();
}
public ActionResult Commit()
{
return RedirectToAction("Index", "GalleryController");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Edit2011.Controllers
{
public class GalleryController : Controller
{
//
// GET: /GalleryControler/
public ActionResult Index()
{
return View();
}
public ActionResult Categories()
{
return View();
}
public ActionResult Overview()
{
return View();
}
public ActionResult Commit()
{
return RedirectToAction("Index", "GalleryController");
}
}
}
Ovo mi je view,
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Overview
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="mainContent" style="width:500px; margin: 20px auto 20px auto; text-align:left;">
Lorem ipsum dolor
</div>
<div id="gallery">
<!-- Ovo je samo test -->
<a href="Index.aspx"><img src="../../Images/1.jpg" alt="My description" title="My title"/></a>
<img src="../../Images/2.jpg" alt="Another text" title="Another title"/>
</div>
<script type ="text/javascript">
Galleria.loadTheme('../../Scripts/galleria/themes/classic/galleria.classic.min.js');
$("#gallery").galleria({
width: 500,
height: 500
});
</script>
<div style="width:800px; margin: 0px auto 0px auto; text-align:center;">
<br /><br />
<form id="Form1" action="/" method="post" runat="server">
<div style="text-align:left; color: Black; width:500px; margin:0px auto 0px auto;">
<asp:Label ID="labelaComment" runat="server" Text= "Unesite vaš komentar:"></asp:Label>
</div>
<br/>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="50px" Width="500px" Rows="0" MaxLength="60" CssClass="commentBox"></asp:TextBox>
<br />
<div style="width:500px; margin:0px auto 0px auto; text-align:right">
<input value="Commit" type="submit" />
</div>
</form>
</div>
</asp:Content>
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Overview
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="mainContent" style="width:500px; margin: 20px auto 20px auto; text-align:left;">
Lorem ipsum dolor
</div>
<div id="gallery">
<!-- Ovo je samo test -->
<a href="Index.aspx"><img src="../../Images/1.jpg" alt="My description" title="My title"/></a>
<img src="../../Images/2.jpg" alt="Another text" title="Another title"/>
</div>
<script type ="text/javascript">
Galleria.loadTheme('../../Scripts/galleria/themes/classic/galleria.classic.min.js');
$("#gallery").galleria({
width: 500,
height: 500
});
</script>
<div style="width:800px; margin: 0px auto 0px auto; text-align:center;">
<br /><br />
<form id="Form1" action="/" method="post" runat="server">
<div style="text-align:left; color: Black; width:500px; margin:0px auto 0px auto;">
<asp:Label ID="labelaComment" runat="server" Text= "Unesite vaš komentar:"></asp:Label>
</div>
<br/>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="50px" Width="500px" Rows="0" MaxLength="60" CssClass="commentBox"></asp:TextBox>
<br />
<div style="width:500px; margin:0px auto 0px auto; text-align:right">
<input value="Commit" type="submit" />
</div>
</form>
</div>
</asp:Content>
Htio bih pozvati akciju Create iz kontolera klikom na dugme input?
Moze li mi ko reci kako da to uradim?