Solved

ASP.NET / Ajax Problem - calling function in orginal Page

Posted on 2011-09-08
6
183 Views
Last Modified: 2012-05-12
Hi,

Have an aspx pageA which calls via jQuery .load() a different aspx pageB into a div on pageA.

On pageB I have a button control which will cause a postback.  The postback returns pageA which is fine.

However, I need the button control on pageB to call a sub on pageA on postback, but I cannot add the reference of the Function on pageA to the AddHandler of the button on pageB.

Any assistance would be appreciated.

Thanks.
0
Comment
Question by:justinkent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
drain earned 500 total points
ID: 36504172
Create the button on page A with the correct handler
hide it with CSS.
have the button that you bring in from page B fire that button on A with JS.
0
 

Author Comment

by:justinkent
ID: 36504670
Hi drain,

A damn good idea!

I added the button to pageA, passed it's ClientID through the querystring to the Ajax page, and then got the onclick handler of the button on pageB to click the button on PageA.

However, the response was that the object of the button on PageA was null. In which I guess the JS on pageB can't see it.

0
 

Author Comment

by:justinkent
ID: 36504714
Scrap that - I was assigning the ClientID from the Querystring to a variable AFTER I had assigned the onclick Event Handler!

Cheers - works as I need!
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:justinkent
ID: 36505822
Hi drain,

I know this query is solved, but immediately ran into another issue which is that the PageA can not access the form controls (textbox, listbox) of the PageB page.

Any ideas?

Thanks.
0
 
LVL 4

Expert Comment

by:drain
ID: 36506460
You'll want to look at what kind of html the pageb is putting out.
I assume you want to access the form controls via JS. You won't be able to access them via .NET

But if your form controls on Page B are ASP controls they likely have some things added to the IDs on the page so
<asp:whatever id="blah" runat="server"/>
would become
<whatever id="pageidentifier_blah" />

So your JS has to access the pageidentifier_blah instead of just blah.

Firebug or the like should help you find the correct IDs if you are not sure...
0
 

Author Comment

by:justinkent
ID: 36506585
Thanks drain... very helpful.

:o)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question