Showing posts with label written. Show all posts
Showing posts with label written. Show all posts

Wednesday, March 28, 2012

Accessing Masterpage Ajax control from Web user control

Hi all,

I have created a master page in asp2.0 and i have placed ModalPopupExtender in that. I have written a custom Textbox control. In that text Changeded event i have created reference to the Masterpage modalpopupextender using Findcontrrol method. But i cant able to loop through tge Master page controls Properly. I am unable to findthe controls with its client id. Can anybody know how to solv this.

My aim is to call the modalpopupextender show event from the custom control.

<cc1:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="btnForLookup"PopupControlID="LookupPanel"BackgroundCssClass="modalBackground">

Private

Sub AHNLookup_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Click

{ Dim contr as ModalpopupExtender

Contr = Me.page.master.FindControls("ModalPopupExtender1")

Constr.show() -->Gives error as Null object.

}

====

Thanks in advance.

S.Sathishraja

Hi,

Please try to find it in a recursive way.

public?Control FindControlRecursive(Control root, string id)
{
????if (root.ID == id)
????{
????????return root;
????}

????foreach (Control c in root.Controls)
????{
????????Control t = FindControlRecursive(c, id);
????????if (t != null)
????????{
????????????return t;
????????}
????}

????return null;
}
Hope this helps.

Monday, March 26, 2012

Accessing AJAX.NET app as part of ASP application

I have written a ASP.NET appliacation named IIC with AJAX features for filling the GridView without refreshing the page when user filters data by using dropdowns and checkboxes. The application is working fine when I run it indepently as follows:

http://localhost/IIC/default.aspx

But this application needs to be the part of our existing ASP application called "Aspapp". So I moved my AJAX enabled ASP.NET application folder as sub folder to ASP application and accessing the page using the following URL:

http://localhost/Aspapp/IIC/default.aspx

Now everything works fine, but except the AJAX. The page refreshes when I fill the GridView.

I copied AjaxControlToolkit.dll and other ASP.NET application related dlls to the bin folder of "Aspapp/bin" application and also "Aspapp/IIC/bin" folder.

I have checked the IIS settings, so that the application is configured to run using .NET 2.0 framework.

My questions are:

1. Am I missing any other assemblies related to AJAX to be copied?

2. Am I copying the assemblies to the right folder?

3. Am I missing any IIS configuration?

Please help.

In IIS make the create a IIC virtual directory. This will cause IIC to run as an independent application and should allow the AJAX to work.


Thanks aquillin.

I fixed the problem. I noticed a javascript error "'Sys' is undefined" is thrown on my ASP.NET page in the ASP application. Then I did research on this error and found a usefull link on the net http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx and came to know that its the problem in the web.config file.

I supposed to add the AJAX specific entries to the web.config file. But the new issue was the ASP.NET application works indepently and I didn't made any changes to it while copying it as a sub folder for ASP application. After little research on the ASP applicatoin I found that there is another web.config directly under the /AspApp folder. So copied the <System.web.extensions> and other AJAX specific configurations to /Aspapp/web.config from /Aspapp/IIC/web.config and everything started working fine.

Access Denied

Not sure if this is the correct forum so sorry if it needs moving...

I have a written a plugin for a client that they have embedded in their website using a simple IFRAME

Everything was been working fine until I added a really simple Ajax control.

The page display fine and the ajax actions and other controls all work as expected.

But if a user clicks on any link on the page i get an 'Access Is Denied' error.

When I debug I am directed to the ScriptResource.axd and the line 5959:

'var offsetL = w.screenLeft - top.screenLeft - top.document.documentElement.scrollLeft + 2;'

I am aware of the cross domain issue and have added:

'Response.AddHeader("P3P","CP=""CAO PSA OUR""")'

..to my code but I cannot get around this error.

I can continue by choosing not to debug but I want fix the problem.

Anyone got any ideas what the problem is?

Thanks for any help

Geoff

I am having the same problem, and cannot figure out how to correct. I have researched it on and off for weeks. Any help on this topic on this issue would be great.

Wayne


I am having the same problem, and cannot figure out how to correct. I have researched it on and off for weeks. Any help on this topic on this issue would be great.

Wayne


Hi Geoff,

Please refer to these entries:

http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx

http://weblogs.asp.net/bleroy/archive/2007/01/31/how-to-work-around-the-quot-access-denied-quot-cross-domain-frame-issue-in-asp-net-ajax-1-0.aspx

Hope this helps.


Whether error that you are facing in IE or Mozilla ?

Because some issues will be there with Mozilla....

Sometimes, You have to add your website in Trusted Site zone...


Hi All,

Many thanks for the responses.

The solution was as Raymond suggested - many thanks!Smile

The link:

http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx

..fixed it for me.

Wayne - If you are having the same problem check out the above link.

All the best

Geoff

Saturday, March 24, 2012

abortPostBack(); is not working..

Hi, I

I have written a javascript file as

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)

{

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus);

}

function CheckStatus(sender, args)

{

var prm = Sys.WebForms.PageRequestManager.getInstance();if (prm.get_isInAsyncPostBack() & args.get_postBackElement().id =='CancelRefresh')

{

alert('cancelling');

prm.abortPostBack();

alert('cancelled');

}

}

if(typeof(Sys) !=="undefined") Sys.Application.notifyScriptLoaded();

----------------

I have written this to cancel my dropdown list postback But request is not cancelling.

My .aspx code.. is

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Scripts>

<asp:ScriptReferencePath="Cancel.js"/>

</Scripts>

</asp:ScriptManager>

<div>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:DropDownListrunat="server"ID="ddl_testing"OnSelectedIndexChanged="ddl_testing_SelectedIndexChanged"AutoPostBack="True">

<asp:ListItemText="Manoj"></asp:ListItem>

<asp:ListItemText="Atul"></asp:ListItem>

<asp:ListItemText="Punit"></asp:ListItem>

</asp:DropDownList>

<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><br/>

<br/>

<asp:ButtonID="CancelRefresh"runat="server"Text="Cancel"/>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

While my .cs code is as follow..

protectedvoid Page_Load(object sender,EventArgs e)

{

Label1.Text = ddl_testing.SelectedItem.Text;

}

protectedvoid ddl_testing_SelectedIndexChanged(object sender,EventArgs e)

{

System.Threading.Thread.Sleep(2000);

Label1.Text = ddl_testing.SelectedItem.Text.ToString();

}

}

But my ajax request is not cancelling on clikcking cancel button ..Can anybody tell me why..

Thanks in advance..

Since the Cancel button resides in the UpdatePanel it appends the NamingContainer in the ID.
Try indexof instead of exatct match:

args.get_postBackElement().id.indexOf ('CancelRefresh') > -1