Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Wednesday, March 28, 2012

Atlas with javascript

I will try to put an update panel around a content place, in order to assure only the "inside" pages will be refreshed, leaving the master page static. There might work I suppose...

Is there any problem in registering our own javascript in a page that has an Atlas control like updatepanel ? If yes, how could it be worked around?

Hi

Should be able to just register your Javascript with the script manager on the page. If the javascript is going to be put in the master page then add the script manager to the master page and register the script in the code behind for the master page.

If you need to register more stuff in the content pages use the ScriptManagerProxy in the content page as you can only have a sing le script manager on a page.

A good over view ishttp://www.nikhilk.net/AtlasScriptManager.aspx

Hope that helps


Hi,

in addition to what Richard Line wrote; if you're going to inject JavaScript code (or script references) in a page after a partial postback, then you must rely on the static RegisterXXX methods of the ScriptManager.

Atlas web service proxy undefined - bug or mistake?

Ok, here's the deal: I have javascript method that is called on the window's load event:

window.onload = function () { getDataForTable();};

Pretty striaghtforward, right? Well, when the getDataForTable method executes it calls an Atlas proxy method:

WebServices.Callbacks.CalendarFunctions.CheckDate(dateField.value, getDataForTable_Callback);
But when the script execute on load, I get an error stating that 'WebServices' is not defined. When I check the HTML output the Atlas javascript reference is there: "text/xml-script">"http://schemas.microsoft.com/xml-script/2005"> <references> <add src="http://pics.10026.com/?src=/Anthem/Callback/CalendarFunctions.asmx/js"/> "text/xml-script">"http://schemas.microsoft.com/xml-script/2005"> <references> <add src="http://pics.10026.com/?src=/Anthem/Callback/CalendarFunctions.asmx/js"/>
<script type="text/xml-script"><page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <references> <add src="/Anthem/Callback/CalendarFunctions.asmx/js" /> </references> <components /></page></script>
And when I hit the URL above the javascript there looks correct:
Type.registerNamespace('WebServices.Callbacks'); WebServices.Callbacks.CalendarFunctions=new function() {this.path = "http://localhost:64408/Project/Callback/CalendarFunctions.asmx"; this.appPath = "http://localhost:64408/Anthem/"; var cm=Sys.Net.ServiceMethod.createProxyMethod; cm(this,"CheckDate","date"); }

So... here is the question: why is this undefined? I think this is a bug because when I debug the script the ".asmx/js" script is not loaded in the script explorer window like other referenced scripts. So, any work arounds? How else do I get this call to execute during the window.onload event?

Thanks in advance for the help.

The best thing to do I think is to install something like fiddler, and verify that the request going out is in the form you expect, and that you are indeed getting the javascript that you get when you use the script include. Hopefully you'll see something obvious...

Actually I think this might be a timing issue, you are probably calling your onLoad before atlas has a chance to load its scripts, so you can verify that is the case in fiddler. Anyways you probably want to register your getDataForTable on pageLoad or using atlas's ApplicationOnLoad.

Hope that helps,
-Hao


You are right, I added the getDataForTable method after I posted this and it worked - it was just a timing issue. Thanks for the help though!

Monday, March 26, 2012

Atlas UpdatePanel, EnablePartialRendering, and a custom javascript problem.

Hi all,

I have a javascript that renders custom tooltips on onmouseover events of objects on my pages, for example an A element. The custom javascript points the elements onmouseover event to delegates. This works fine except however when an UpdatePanel is render after the page has initially loaded. The function pointers are lost by objects within the UpdatePanel.

How can I setup an client side event procedure that can be run everytime the UpdatePanel renders something so that I can reinstate the lost function pointers?

Or, is there a better way to do this?

Thanks,

Andeezle

Please allow me to simplify my question. In other words, how can i run a client side script after an updatepanel updates?

also, i need a reference to the updatepanel that updated.

-Thanks,

Andeezle


Hi,

please check theUpdateProgressSignup written bySimone Busoli.

Thank you. Very cool. And it worked too!!!

-Andy

Atlas Unknown Error Popup on Session Exipry - Requesting fix

Hi,

I did some invesitgation on the"Unknown Error" javascript popup and it does happen when the session expires and the user performs an operation on the page. I am not able to get rid of this problem, eventhough the code checks for session expiry. The page doesn't load in the first place to call the function given below. Instead the unknown error popup appears . We are looking for a fix as soon as possible as we are going live next month . This is critical as almost all the web pages in the application is using atlas updatepanel. Can anyone please provide a solution to this problem.

Thanks in Advance,

Vikram

Session Expiry Server Side Code:

privatevoid CheckSessionExpiry()

{

string appPath = Request.ApplicationPath;if (appPath !="/")

appPath = appPath +

ConfigurationManager.AppSettings["SessionExpiryPage"];else

appPath =

ConfigurationManager.AppSettings["SessionExpiryPage"];string headerval =Convert.ToString((Session.Timeout * 60) - 45) +";URL=" + appPath;Response.AppendHeader("Refresh", headerval);if (Session["sUserID"] ==null)

{

Response.Redirect(appPath);

}

}

Unfortunately, there's no adequate solution. I'm facing the problem myself and I wonder when it's going to be fixed. You can browse through the forum to see I'm right.
If you are using other Java-Script functions on your page, I have found it matters if you have your SCRIPT tag with language=javascript or language="javascript" and if it is the HEAD of your HTML or in the BODY of your HTML.

If in the HEAD of your HTML, I have found that you need to have the double quotes [ language="javascript" ]

If in the BODY of your HTML, double quotes do not seem to matter, with or with out double quotes seems to work just fine.

For more detail:
http://jblack.wordpress.com/2006/08/18/javascript-or-javascript/

Hi,

Thanks for your reply. But unfortunately I do have language="javascript" . So what else could be the problem .

We use simple javascripts for doing some client side validations. Could they sometimes cause atlas to give raise to unknown error problem ?

Example 1:btnCompareBenefits.Attributes.Add("onclick", "return CompareClick();"); CompareClick function is in a .js file.

Example 2:deleteButton.Attributes.Add("onclick", "return confirm (\"Are you sure you want to Delete? \");");

Thanks in Advance,

Vikram


Hi All,

I am also experiencing an issue where I get unknown error.

My issue only happens when I wrap asp.net 2.0 controls in an update panel. The strangest thing is that this is only happening in one of two projects that uses the same ASP.net controls. In one I get the updates working fine in the other I get unknown error. The only difference as I can see is that n the project that doesn't work correctly the controlls are nested more deeply. I have a panel surrounding a header and body panel, giving the appearance of a window and the update panel is inside the body panel so the controls are 3 panels deep in design mode. In the project where it all works the controls are one panel deep only as they are inside an update panel only.

I have tried th javascript "javascript" fix as well and the ampersand fix and validaterequest="false" in the page tag... none work, the only way to stop the error is to avoid placing any asp.net control inside an update panel.. Then I get a postback :0(

This issue is crippling us at the moment.


My issue was totally the reverse! I have an ScriptManager on my masterpage. The "Unknown Error" popup was occuring on a page with no UpdatePanel. When I wrapped the asp.net 2 control on the page in an UpdatePanel the popup went away.

Bump.

I am also having this problem


I had this issue as well. I did find an acceptable work arround. Create and<ErrorTemplate> section within the ScriptManager tag. This will eliminate the JavaScript popup alert. Then you can have a firendly erro message asking the user to relogin and provide a link to the login page. Something like this:

<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"OnPageError="Page_ErrorHandler"runat="server">
<ErrorTemplate>
<divclass="ErrorDialog">
<div>
<asp:ImageID="Image1"ImageUrl="~/images/error.gif"ImageAlign="AbsMiddle"runat="server"/>
<spanstyle="font-size: 16pt; font-weight: bolder;">Server Error</span>
</div>
<div>
You encountered an unexpected error. The error has been logged and will be investigated.
</div>
<div>
<ahref="login.aspx">click here to re-login.</a>
</div>
</div>
</ErrorTemplate>
</atlas:ScriptManager>

See ErrorTemplate doc for more info:http://atlas.asp.net/docs/Server/Microsoft.Web.UI/ScriptManager/P_ErrorTemplate.aspx

Hope this helps,
Perry


Remove lineResponse.AppendHeader("Refresh", headerval); & try again with correct session timeout methods.

remove any response.write statements & replace them with this.page.clientscript.registerclientscriptblock();

we have no problems with session timeout.Updatepanel works even if session is expired

Amit Lohogaonkar

mcp,mcad

lohogaonkaramit@.yahoo.com


Hi,
I have found this problem several times. finally I was able to corner it in my case.
I was using several UpdatePanels on my page and have few javascript functions within SCript tag in HEAD section of page.
It is important to note that whnever javascript function contains "postfix increment operator" i.e ++ or "postfix decrement operator" i.e. --, it will throw "Unknown Error".

Similarly whenever javascript function contains "logical AND operator " i.e. && "logical OR operator" i.e. ||, it throws the "Unknown Error".
However, if these functions are inside "BODY" tag then it works just great. Or if they are moved to a separate JS file and then include it in HEAD tag, it all works fine.

Hope this helps.
Mayur


Hi

still face same problem,

Regards,

Sarfaraj Sayyad


I'm guessing you guys are using ASP.NET Forms Auth - and the login cookie is expiring.

From what I can tell, ASP.NET Ajax throws an "Unknown Error" when it makes a XmlHttp call and gets a response which isn't what it was expecting.

In the case of a session expiry, instead of the page fragment it was expecting it suddenly gets back a "You need to login" page, or a 500 error, or a 404.

It doesn't know what to do, and dies with an "Unknown Error".

I'm going to try out that ErrorTemplate example pasted in one of the replies above and see if that does it for me.


I'm also getting the same 'Unknown error' alert when the session expires. Without Atlas on the page there is no problem. I can trap errors and modify the ErrorMessages of other page errors with with the 'OnPageError' event of the script manager but it won't trap the 'Unknown error'. I assume this is because the server code is not executed as Atlas is not able to deal with the expired session. My page continues after the alert and renews the session but I would like to avoid this error or at least be able to modify it.
I've discovered since my last post that the "Unknown error" only occurrs when the new session trys to redirect to a different page. In my app when the session starts it checks certain conditions and may redirect. If there is no redirect it renews the session without error.

I'm facing the same problem.

As I'm not using any other client side javascript than the one built in the atlas controls I can eliminate script specific error reasons.

Saturday, March 24, 2012

ATLAS ToolKit problem

Hi,

I am using watermark textbox in my application but it gives javascript error while execution.

What should be the problem ?

Please help me.

Thank You,
Bhavin Gajjar

I give you an example about how to use watermark textbox.Wish this will help you.You can post your javascript error messages and your code here.I suggest you to do web application development using asp.net 2.0.There are many new features in asp.net which are convenient to do WAD.

<atlas:ScriptManager id="ScriptManager1" EnablePartialRendering="true" runat="Server"></atlas:ScriptManager>

<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
First name:
<asp:TextBox ID="TextBox1" CssClass="unwatermarked" Width="150" runat="server"></asp:TextBox>
<br />
Last name:
<asp:TextBox ID="TextBox2" CssClass="unwatermarked" Width="150" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
<br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>

<atlasToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server">
<atlasToolkit:TextBoxWatermarkProperties TargetControlID="TextBox1" WatermarkText="Type First Name Here" WatermarkCssClass="watermarked" />
<atlasToolkit:TextBoxWatermarkProperties TargetControlID="TextBox2" WatermarkText="Type Last Name Here" WatermarkCssClass="watermarked" />
</atlasToolkit:TextBoxWatermarkExtender>


Hi,

Thank you for update still not get solution.

Below is HTML script.

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="PostTopic.aspx.cs"ValidateRequest="false"Inherits="PostTopic" %>
<%@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="cc1" %>
<%@.RegisterAssembly="FredCK.FCKeditorV2"Namespace="FredCK.FCKeditorV2"TagPrefix="FCKeditorV2" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Demo Water mark</title><linkhref="StyleSheet.css"rel="stylesheet"type="text/css"/>
</head>

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

<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server"></atlas:ScriptManager>

<tableborder=0align=centerwidth="80%"cellpadding=0cellspacing=0><tbody><tr><td>

Topic Heading :

<atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:TextBoxID="TextBox1"CssClass="unwatermarked"runat="server"></asp:TextBox>
</ContentTemplate>
</atlas:UpdatePanel>

<cc1:TextBoxWatermarkExtenderID="TextBoxWatermarkExtender1"runat="server">
<cc1:TextBoxWatermarkPropertiesTargetControlID="TextBox1"WatermarkText="Bhavin"WatermarkCssClass="watermarked"/>
</cc1:TextBoxWatermarkExtender>

</td>

</tr>

<tr>

<td>

Content : <BR>

<fckeditorv2:fckeditorid="FCKeditor2"runat="server"BasePath="FCKeditor/"></fckeditorv2:fckeditor>

</td></tr><tr><td>
<asp:ButtonID="btnSubmit"runat="server"Font-Bold="True"Text="Submit"/> <asp:ButtonID="btnCancel"runat="server"Font-Bold="True"Text="Cancel"/>
</td></tr><tr><td> </td></tr><tr><td>Topic Posted:</td></tr><tr><td><asp:LabelID="lblComment"runat="server"></asp:Label>
</td></tr></tbody></table></div></form></body>
</html>

===========

This is my code n Other things are working only script i get is " }" missing but then i tried to compile but got getting.
Next i enter text to text box n it prompt error like "Sys" is undefined.

What is wrong.

Help me.

Thank you.


Hi Bhavin,

If you're seeing "Sys" is undefined, then there's a problem loading your "Atlas" scripts. Can you get any other "Atlas" related pages in your project to work? Also, have you modified the TextboxWatermarkBehavior.js file in anyway that could cause an error?

Thanks,
Ted

Hi,

i have only 1 page in my project as i was testing ATLAS first time.

The script i sent you is what i am having on my page and i have not changed any thing in script files.

Thank you.


Hi Bhavin,

Then my guess would be that you created a regular ASP.NET site instead of an "Atlas" site which could explain why the "Atlas" scripts aren't getting loaded. Perhaps you could try creating a new project and follow along with theSetup Your Environment andUsing a Sample Extender Walkthroughs.

Thanks,
Ted

Atlas Toolkit Calendar

Does anyone know how to change the selected date in the calendar through client side javascript? I want to verify the date selected is today or later and if it is not then I want to reset the date in the calendar to today's date.

Thanks,

Eric

I don't think you can do that without a postback, you can put that calendar between an UpdatePanel and will look like is client side. Otherwise you may have to use another control. There are plenty on the web

I finally figured it out. The ajax toolkit calendar control, and some of the otehr controols, has a BehaviorID property which can be assigned any value I guess. I called it 'CalBehavior1'. Once that was done, I looked in the JS source file for the control in the source code of the AjaxControlToolKit. In that JS file, I saw the various methods and properties that are exposed on the client side. I have an OnClientDateSelectionChanged event handler attched to the control, so everytime the user selects a date I have some JS code that verifies the selected date is today or later. To set the date in the calender to today, I do the following:

$find(

'CalBehavior1').set_selectedDate($find('CalBehavior1').get_todaysDate());


I finally figured it out while looking at the rounded corners example in the sample website of the Ajax Control Toolkit. The Ajax Toolkit Calendar control, and some of the other controls, has a BehaviorID property which can be assigned any value I guess. I called it 'CalBehavior1'. Once that was done, I looked in the JS source file for the control in the source code of the AjaxControlToolKit. In that JS file, I saw the various methods and properties that are exposed on the client side. I have an OnClientDateSelectionChanged event handler attched to the control, so everytime the user selects a date I have some JS code that verifies the selected date is today or later. To set the date in the calender to today, I do the following:

$find('CalBehavior1').set_selectedDate($find('CalBehavior1').get_todaysDate());

Yea!!!

Eric

Atlas to AJAX- Open Modal Popup from Javascript

Hi,

I know that i can now show the modal popup server side but I have a case where i dont want or need a postback to show the popup. I have buttons in a repeater that and i simply show the modal on click...so in 'Atlas' i did this in javascript..

aspx..

<atlasT:ModalPopupExtenderID="ModalPopupExtender1"runat="server">

<atlasT:ModalPopupPropertiesID="MyPopup"

TargetControlID="Button1"PopupControlID="panModal"CancelControlID="btnCancel"

BackgroundCssClass="modalBackground"DropShadow="True"OkControlID="btnHiddenOK"/>

</atlasT:ModalPopupExtender>


Then in .js

$object("MyPopup")._show();


------AJAX-------

<ajaxT:ModalPopupExtenderID="ModalPopupExtender1"runat="server"

TargetControlID="Button1"PopupControlID="panModalPopup"CancelControlID="btnCancel"

BackgroundCssClass="modalBackground"DropShadow="True"OkControlID="btnHiddenOK"/>


And in .js...

$find("ModalPopupExtender1")._show();


Which doesn't work....Any ideas?

Also, I see properties in the control called Dynamic*; what are they for? Databinding?

Thx
Steve

bump... Anyone got a resolution for this?

Thx
Steve


I thnk that you need to use the show method instead of _show:

$find("ModalPopupExtender1").show();

The dynamic* properties appear to be related to dynamic population. See:


http://ajax.asp.net/ajaxtoolkit/Walkthrough/OtherNeatStuff.aspx

and search for "Easily adding dynamic population"



Thx
Thx cti.

Atlas stopped working when I added a javascript function.

Everything was working perfectly until I added a <script type="text/javascript"> section in the header and added a function. Now Atlas doesn't work any more. The page I created is simply a listbox, button and a label. When the button is pushed items are added to the list box and the label text is changed. With the javascript function in the code, nothing happens when I click the button. It works if the "hasOptions" function is removed. Is this a bug, or am I just doing something wrong?

Here is the aspx code:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function hasOptions(obj) { if (obj != null && obj.options != null) { return true; } return false; } </script></head><body><form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <br /> <atlas:UpdatePanel ID="TableUpdatePanel" runat="server" Mode="Conditional"> <ContentTemplate> <asp:ListBox ID="listbox" runat="server"> <asp:ListItem Text="Hello"></asp:ListItem> </asp:ListBox> <asp:Button ID="button" runat="server" OnClick="button_Click" Text="Push Me!" /><br /> <asp:Label ID="label" runat="server"></asp:Label> </ContentTemplate> </atlas:UpdatePanel> </form></body></html>

And here is the Code Behind:

using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) { }protected void button_Click(object sender, EventArgs e) { listbox.Items.Add("Test"); listbox.Items.Add("Test"); listbox.Items.Add("Test"); listbox.Items.Add("Test"); listbox.Items.Add("Test"); label.Text ="This worked!"; }}

Hi,
I recently posted a message regarding your problem.
Try commenting out the IF statement with the && logical and operator,
that should fix your problem, seriously :)

I assume this is caused by a bug in the Atlas framework.
Every response returned from a partial update is treated as an XML document (you can use WebDevHelper to monitor the HTTP traffic and see this) and because '&' is a special xml charachter it confuses the Xml Parser and causes the Partial Rendering to fail.

I'm still waiting for a reply from for my post regarding this issue.

My Post:
http://forums.asp.net/thread/1267658.aspx

Have fun,
Lidor Pergament.

Wednesday, March 21, 2012

Atlas problems... what versions support on add_pageLoaded hook?

I've inherited a large-ish project that uses a late version of Atlas (not ASP.NET AJAX)

The version in the javascript file headers is 2.021006.A

My problem is I need to hook in a global "Please Wait" message on all Postbacks and Submits.

Hooking into the Form.onSubmit is no problem, and the "Please Wait" message is normally cleared by the page reloading.

However the project uses quite a lot of UpdatePanels and ModalPopUpExtenders. These don't clear the message after a callback (as the page isn't reloaded)

A quick google found a simple solution - Including something like...

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(clearPleaseWait);

..in the Master Page should do most of what I want.

Unfortunately I can't see aPageRequestManager object!Sys andWebForms are there, but there's only 2 properties ofWebForms, one of which is_PageRequestManager which doesn't have any properties of its own.

So, the questions are...

Does the ATLAS version I'm using support/expose PageRequestManager events?Is there still any documentation anywhere for this version?If No and No, is there a workaround for what I'm trying to do?Or have I got to bite a considerably sized bullet and upgrade to ASP.NET AJAX?

Thanks in advance for any much-needed help!!

If it was a pre-beta release, things were done a lot different. We had a few sites that used Atlas or ASP.NET Ajax for a little over a year now, and we had a lot of things that had to be rewritten to work with the beta and newer releases. Most standard server controls for it worked fine, but all our custom stuff had to be rewritten. There may be someone on here that might have some limited documentation somewhere. Most of the documentation was all online and pulled whenever a new release came out.

Does the version your have contain a UpdateProgress control? You may be able to use one in the master page that would work for all the pages that use it. That should display a message during asyncpostbacks and callbacks. I haven't done a lot with the behind the scenes parts of ATLAS or ASP.NET Ajax because it doesn't usually require you to unless you are really fine tuning things, which could be a good and bad thing...

If you do have to upgrade to the newest release now, you may want to run a copy of the site to make changes to while upgrading because that can take some time...