Solved

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

Posted on 2011-09-08
6
184 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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