0

I show modal popup window in default.aspx page so:

<a id="popup" href="../Popup/Keywords.aspx">edit</a>

Jquery function:

$(document).ready(function () {
            $('a#popup').live('click', function (e) {

                var page = $(this).attr("href")

                var $dialog = $('<div></div>')
                .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
                .dialog({
                    autoOpen: false,
                    modal: true,
                    height: 450,
                    width: 'auto',
                    title: "Edit Employee",
                    buttons: {
                        "Close": function () { $dialog.dialog('close'); }
                                },
                    close: function (event, ui) {


                    __doPostBack('<%= grdReportKeywordsRefresh(report_id) %>', '');
                    }
                });
                $dialog.dialog('open');
                e.preventDefault();
            });
        });

How to call "grdReportKeywordsRefresh" method with parameter "report_id" right?

Why controls of Default.aspx page are not displayed in popup window?

report_id:

private String r_id;
public Int32 report_id
{
    get { return r_id != null ? Convert.ToInt32(r_id) : 0; }
    set { r_id = value; }
}

grdReportKeywordsRefresh method:

protected void grdReportKeywordsRefresh(int report_id)
{
    grdKeywords.DataSource = conn.GetKeywordsByRepId(report_id);
    grdKeywords.DataBind();
}
6
  • this calls function while you're rendering page. is it what you want? Commented Jul 13, 2011 at 10:01
  • can you post grdReportKeywordsRefresh method, or at least describe what it is supposed to do? first argument of __doPostBack is supposed to be ID of control of which action you want to run. this can be for example button or etc. alternatively you can just add some string and during page lifecycle (ie in page_load) check for this value (Page.Request("__EVENTTARGET")) and run your code based on that. does this help? Commented Jul 13, 2011 at 11:29
  • @Ales: this method refreshes GridView (I added it to question). Can you show me an example of your alternative solution? Commented Jul 13, 2011 at 12:06
  • @Ales: No, I'm not. I have VS2005 without AJAX Extensions :( Commented Jul 13, 2011 at 12:10
  • i've changed my answer accordingly Commented Jul 13, 2011 at 12:16

3 Answers 3

2

People are right, you're mixing stuff :)

It should go like this:

<script type="text/javascript">
this is what you call:
  __doPostBack('updateMyGrid', '')
</script>

in codebehind (using VB.NET, if you use C#, I'll change it)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Page.IsPostBack AndAlso Page.Request("__EVENTTARGET") = "updateMyGrid" Then
    'rebind your grid here
  End If
End Sub

c# (just frome head)

protected void Page_Load(object sender, EventArgs e) {
  if(IsPostBack && Page.Request["__EVENTTARGET"] == "updateMyGrid") {
    //rebind here
  }
}
Sign up to request clarification or add additional context in comments.

4 Comments

op does appear to be using c# in their sample
Ales, thanks for help, but Page.Request.Params.Get("__EVENTTARGET") (maybe only in c#). And can you say why the .aspx page isn't shown in popup window?
is there some javascript error? i would try to use some html inspector (ie chrome inspector or FireBug) to find reason
yes, I made a stupid mistake, again thanks a lot for your help!
2

You're mixing client and server code.

You're also loading another page altogether into your pop-up, so it's not surprising it's not showing anything from default.aspx.

You could set a value in a hidden field when you close the pop-up, then force the postback & on the server, check if the hidden field value is set and call the function if it is.

Simon

Comments

1

Where is report_id defined? You cannot use variables that are set in javascript because server side code (<%= %>) gets executed when the page is rendered by the server.

3 Comments

report_id is page's class property
Can I see how it is declared?
I added it to the end of the question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.