Dinesh Kumar
asked on
Posting form using anchor tag
Hi,
I am using the following to post the form:
@using (Ajax.BeginForm("SendMessa ge", "User", null,
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "jsMessageSent"
})) {
<input placeholder="Message Subject" class="msg-subject" name="subject" />
<input type="submit" value="Send" class="send-message" onclick="jsCloseComposeMes sage();" />}
BUT I want to post this form using anchor tag instead of input type submit
I tried
@Ajax.ActionLink("testing_ Send", "SendMessage", "User", new { subject ="dines"}, new AjaxOptions { HttpMethod = "POST" })
but its becomes querystring.
Please note that I don't want to change my way of implementing ajax i.e Ajax.BeginForm
because it has been implemented on various places on the project.
Please help!
regards
meetDinesh
I am using the following to post the form:
@using (Ajax.BeginForm("SendMessa
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "jsMessageSent"
})) {
<input placeholder="Message Subject" class="msg-subject" name="subject" />
<input type="submit" value="Send" class="send-message" onclick="jsCloseComposeMes
BUT I want to post this form using anchor tag instead of input type submit
I tried
@Ajax.ActionLink("testing_
but its becomes querystring.
Please note that I don't want to change my way of implementing ajax i.e Ajax.BeginForm
because it has been implemented on various places on the project.
Please help!
regards
meetDinesh
check this link too
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
it tells how to submit a form using jquery post without refreshing the page
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
it tells how to submit a form using jquery post without refreshing the page
ASKER
you are right but this solution does not use
Ajax.BeginForm
Ajax.BeginForm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
but you are not using "Ajax.BeginForm" here also!!
ASKER
The complete code is:
<div class="abc">
@using (Ajax.BeginForm("actionNam e", "User", null,
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "ok"
}, new { id = "SendMessage9" }))
{
<div class="popup-top-container ">
<div class="popup-prodetails">
<div class="top-txt">
Messaging to:</div>
<div class="msg-container">
<input type="text" class="userid" name="receiver" placeholder="Type your Friends Names Here" />
<div class="user-select-opt">
</div>
</div>
</div>
<div class="popup-cancel-btn">
<input type="button" value="CANCEL" onclick="jsCloseComposeMes sage();" class="popup-cancel2" />
</div>
</div>
<div>
<input placeholder="Message Subject" class="msg-subject" name="subject" />
</div>
<div class="msg-rply-container" >
<input type="submit" value="Send" class="send-message" />
<a href="javascript:postMessa ge();">Che cking</a>
</div>
<script language="javascript" type="text/javascript">
function postMessage() {
$("#SendMessage9").submit( );
jsCloseComposeMessage();
}
</script>
}
</div>
<div class="abc">
@using (Ajax.BeginForm("actionNam
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "ok"
}, new { id = "SendMessage9" }))
{
<div class="popup-top-container
<div class="popup-prodetails">
<div class="top-txt">
Messaging to:</div>
<div class="msg-container">
<input type="text" class="userid" name="receiver" placeholder="Type your Friends Names Here" />
<div class="user-select-opt">
</div>
</div>
</div>
<div class="popup-cancel-btn">
<input type="button" value="CANCEL" onclick="jsCloseComposeMes
</div>
</div>
<div>
<input placeholder="Message Subject" class="msg-subject" name="subject" />
</div>
<div class="msg-rply-container"
<input type="submit" value="Send" class="send-message" />
<a href="javascript:postMessa
</div>
<script language="javascript" type="text/javascript">
function postMessage() {
$("#SendMessage9").submit(
jsCloseComposeMessage();
}
</script>
}
</div>
ASKER
This solution worked well.
$("#testing_Send").attr("h
postForm()
{
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: "html"
});
}