Mình có 2 button submit ở trong 1 form, gồm button click tìm kiếm 1 cái là button đăng bình luận. 2 cái button này hoạt động song song không được. phải xóa 1 trong 2 cái thì nó mới hoạt động được . Có bác nào biết cách giúp 2 cái hoạt động song song không?? :((
Giúp đỡ về việc xử lý 2 button submit trong 1 form ASP.NET
Bạn đặt 2 button là ASP:Button
nhé, đừng dùng input type="submit"
, cái đó là của HTML, đưa vào ASP.NET nó dở ông dở thằng lắm =))
Thử xem thế nào,
<form>
[fields]
<input type="submit" value="Submit to a" formaction="/submit/a">
<input type="submit" value="submit to b" formaction="/submit/b">
</form>
hoặc
<input type='submit' value='Submit' onclick='this.form.action="somethingelse";' />
<button type="submit" id="btnS" name="Command" value="Search">Search</button>
<button type="submit" id="btnC" name="Command" value="Comment">Comment</button>
[HttpPost]
public ActionResult MultipleCommand(RegistrationModel mReg, string Command){
if(Command == "Search"){
// do search here
}
if(Command == "Comment"){
//do comment here
}
}
ùm mình dùng asp:button luôn :v