开发者

Populate a jquery dialog launched from a gridview

I have a gridview that I wish users to be able to click the View link and it pop up a jquery dialog with more data displayed from the row which the button is in. I am using a link button which displays the pop up but I wish to run server side (asp .net) prior to this in order to populate the fields on the jquery dialog before it is displayed

<asp:LinkButton ID="btnViewDetails" runat="server" Text="View" CommandName="ViewDetails"
                                CausesValidation="false" CommandArgument='<%#Eval("CustomerID")%>' 
                      开发者_高级运维          OnClientClick="showDialog('viewCustomer');"></asp:LinkButton>

I have tried populating the controls in the RowCommand but this fires after the jquery popup has been displayed, resulting in the next time I click on a row's 'View' button, it displays the data from the previous row that was selected.

Greatly appreciate any help


I suggest you to not trigger the dialog at OnClientClick. Instead you can trigger a AJAX call which populates the data to be displayed from the server side. And trigger the dialog on successful AJAX completion.

something like this

OnClientClick="TriggerAjax(yourInput)"

in javascript

function TriggerAjax(input) {
          $.ajax({
                      url: "SeverPage.aspx?input=" + input
                      cache: false,
                      success: function(response) {
                            showDialog(response);
                      }
                    });
}


You inject javascript from your code-behind to open dialog something like this:

string script = "$(function(){showDialog('viewCustomer');});";
ScriptManager.RegisterStartupScript(this, this.Page.GetType(), "showdialog", script, true);
//Or if not using ScriptManager
//Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "showdialog", script, true);

In your showDialog you open the jquery dialog. Check these:

Show jQueryDialog from code-behind

Inject javascript from code-behind

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜