Solved

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

Posted on 2011-09-08
6
181 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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