Help with RegisterPostBackControl

I have the code shown below.  This was suggested, and works, as a may to prevent an error message I was getting after doing a Response.WriteFile as a result of clicking the btnExcelExport.   However, this code is causing me another issue.  This code is on a main page which has an Add button that invokes javascript to display a modal popup.   If I cancel out of the modal popup, which is done using the bit of javascript shown below, some of the data that was displayed on my main page disappears.    Now, I was under the impression that the javascript "cancel" code I have below would only close the Add modal popup, and not impact the underlying main page.  However, Page.Init does get called.

So, two questions - 1) When the user clicks cancel on the modal popup, is there code I can add so that  Page.Init on the underlying page is not called?   2)  Why does RegisterPostBackControl cause other data on the page to disappear?  



Public Sub Page_Init() Handles Me.Init

      Dim sm As ScriptManager
      sm = CType(FindControlRecursively("ScriptManager1"), ScriptManager)
      sm.RegisterPostBackControl(Me.btnExcelExport)

End Sub




function cancel() {
                  
      window.returnValue = "cancel";
      self.close();
      return false;
}
LVL 1
HLRosenbergerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ArkCommented:
What is 'Cancel' button? Server control or html input?
0
HLRosenbergerAuthor Commented:
I moved the code to Page.Load and this fixed the problem.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HLRosenbergerAuthor Commented:
fixed the problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.