views:

26

answers:

1

I'm trying to bring over the IDs of the input elements "submit" and "skip" and do some logic based on which button was pushed. It doesn't appear to be coming over in the Request object. How can I do this???

<div id="modal">
    <% using (Ajax.BeginForm("Promo", new AjaxOptions { UpdateTargetId = "modal" }))
       { %>
    <div id="modal_inner">       
        <div style="clear: both;">
            <%= Html.TextBox("Data1")%>
            <input name="submitBtn" id="submitBtn" type="image" src="button_submit.gif" width="74" alt="Submit" />
            <input name="skipBtn" id="skipBtn" type="image" src="button_skip.gif" alt="Skip" />            
            <br />
        </div>
    </div>
    <% } %>
</div>

public JavaScriptResult Promo(string Data1)
        {
            string submitBtn = Request.Params["submitBtn"];
            string skipBtn = Request.Params["skipBtn"];
            if (skipBtn != null)
            {
                Session["Data1"] = "Default";
                return JavaScript("window.top.location.href ='" + Url.Action("Index", "Lead") + "';");
            }
            if (submitBtn != null && IsValidCode(Data1))
            {
                Session["Data1"] = Data1;
                return JavaScript("window.top.location.href ='" + Url.Action("Index", "Lead") + "';");
            }
            Session["Data1"] = "Default";
            return JavaScript("$('TB_window').dispose(); TB_show('', '#TB_inline?&width=344&height=294&inlineId=modal', '::::');");
        }
A: 

I had the same problem using jQuery, it would not serialize the name of the form element I clicked. I had to seperately detect the onclick of the submit button, get the name of the button, and add it to the serialized query to be sent back with the Ajax call.

Sorry I do not know which Ajax framework you are using here so I cannot help with the actual code.

Will Earp