Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,
I created edit button dynamically button dynamically with the following code.
JavaScript
ed = "<input style='height:22px;width:55px;' type='button' value='Edit' onclick=\"editSection('" + last_row + "');\"  />";


and i am calling editSection(rowToBeEdited) function
JavaScript
function editSection(secIndex) {
    alert("edit row="+secIndex);
    var userid=   $("#UserID").val('');
    $("#UserName").val('');
    
    var myGrid = $("#UsersGrid");
    
    $("#UserName").val(myGrid.jqGrid('getCell', secIndex, 'UserName'));
    
    $("#btnUpdate").css("display", 'inline');
    $("#POPUP").dialog({ width: 400 });
}

and i am displaying the popup data is
ASP.NET
<table id="UsersGrid"></table>
    <div id="UsersGridPager"></div>
<form  id="commentForm"  runat="server">
    <div id="POPUP" style="display:none;">
        <fieldset>
        <p>
             <label for="UserName">User Name:</label>
             <input id="UserName" name="UserName" size="25" class="required" />
        </p>
        <p>
             <input id="btnUpdate" type="button" value="Update"  önclick="saveEditedData()" /> 
             <input id="cancel" type="button" value="Cancel"  önclick="cancelChanges()" />
        </p>
        </fieldset>
    </div>
</form>


on update button click i am calling the saveEditedData()

JavaScript
function saveEditedData()
{
     var userName = $("#UserName");
    
    $.ajax({
        url: "editRow.ashx?UserID=" + 9 + "&UserName=" + UserName.val(),
        cache: false,
        crossDomain: true,
        dataType: "jsonp"
        }).done(function (secIndex) {
            // handle the output here
            alert(secIndex.Response.id + " is edited ");
            $("#UsersGrid").trigger("reloadGrid");
    });
    
    $("#POPUP").dialog('close');
}

function cancelChanges()
{
    // alert("closed");
    $("#POPUP").dialog('close');
}

The main problem is when i am passing value like url: "editRow.ashx?UserID=" + 9 + "&UserNe ame=" + UserName.val(), the editRow.ashx is not calling ?

How can I get this date from ashx page?
Posted
v3
Comments
Dholakiya Ankit 20-Sep-13 0:53am    
Any error you are getting when calling 500? 404 ?
More chances of getting ans = provide details as much as possible :)
Naga Sindhura 20-Sep-13 1:18am    
i am not getting any error

1 solution

Issues

I can see some logical issues in the below function.
JavaScript
function editSection(secIndex) {

    alert("edit row="+secIndex);
    var userid=   $("#UserID").val('');
    $("#UserName").val('');
    
    var myGrid = $("#UsersGrid");
    
    $("#UserName").val(myGrid.jqGrid('getCell', secIndex, 'UserName'));
    
    $("#btnUpdate").css("display", 'inline');
    $("#POPUP").dialog({ width: 400 });
}


Let's discuss underlined items

  • JavaScript
    var userid=   $("#UserID").val('');

    This line will simply set value blank in UserID field (as you specified '' inside the val methos). Then blank gets assigned to variable userid.

    Instead, you should do the below.
    JavaScript
    var userid = $("#UserID").val();

  • JavaScript
    $("#UserName").val('');

    Same problem here. It will set blank in UserName field.


So, inside the function saveEditedData, it will give you blank values.


Suggestions


  • Make sure editRow.ashx is inside the same folder as of this page
  • Check if there are any errors in Developer Tool's Console tab like FireBug Console tab in FireFox or not. If it is showing errors, then correct you code
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900