We help IT Professionals succeed at work.

JavaScript Open Popup Window - Postback

smithmrk
smithmrk asked
on
OK, I have a JavaScript that opens a Popup Window and when first clicked it runs the Page_Load (Postback).

After I close the window and click it to open again, the 2nd time the Page_Load (Postback) does NOT work.  How can I force my LinkButton that runs the Popup Window to force the Page_Load (Postback) everytime?

Thanks,
Mark
Comment
Watch Question

Hi

Pl put Ur Code, then only we can get the where error we will know

-as of my understanding Bellow URl Help U

http://forums.devx.com/showthread.php?threadid=143380

Author

Commented:
I should have probably sent you some screen shots and code in the first post.
OK, I'm going to label the screen shots A, B, C so I can reference them for you better.
function TMA_Popup()
{
    var sitenum = getQuerystring('SiteNum');   
    var clntnum = document.getElementById('<%=txt_ClientNum.ClientID %>').value;
    
    window.showModalDialog('tma_codes.aspx?SiteNum=' + sitenum + '&ClientNum=' + clntnum,null,'height=450, width=450,status=no, resizable=no, scrollbars=yes, toolbar=no,location=no,menubar=no');
}
function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

Open in new window

A.jpg

Author

Commented:
Opps, here are the rest of the screen shots..

OK So on screen shot "A" is the link button that runs the JavaScript that opens my Popup of codes "B".  Once the operator selects the codes they want they click OK and the codes are loaded to a database, and I close the window using JavaScript (window.close()).

If the operator made a mistake and want's to select more or remove one and they click the "A" link button again the popup window comes up...however it does NOT run the Page_Load "C" (IsPostBack = False).  How can I reset it so if the operator returns to this popup page it runs the PostBack again to update my codes based on what they checked or unchecked the first time?

Hope that helps!

Thanks,
Mark
B.jpg
C.jpg
Commented:
Odd...
How about avoiding caching by making the url unique.
Just add the timestamp to the url and see if that helps...
var url = 'tma_codes.aspx?SiteNum=' + sitenum + '&ClientNum=' + clntnum + '&t=' + new Date().getTime();
window.showModalDialog(url,null,'height=450, width=450,status=no, resizable=no, scrollbars=yes, toolbar=no,location=no,menubar=no');

Open in new window

Commented:
You're initial description of the problem is a little confusing, but after reading the follow up I would suggest that the approach is flawed.

Instead of using the page_load event and firing your Client_TMACodes() function based on the "PostBack" property you should attach an OnClick event to your linkbutton and fire your Client_TMACodes() function from inside of that event.

Or (and I dont know how the rest of your page functions) just remove the "call ClientTMA_Codes()" from the If postback = false statement and it will fire everytime.

Author

Commented:
That worked perfect!!!!

Thanks,
Mark