Showing posts with label hence. Show all posts
Showing posts with label hence. Show all posts

Monday, March 26, 2012

Without installing Atlas, Website application is not working in IE

Hello,

I am developing Website Application using VS 2005 with .NET 2.0 and Atlas June CTP. I am using Atlas framework in the existing project. Hence I have added reference of Atlas.dll and modified Web.config

In the project, I have one user control (ascx) and one aspx page. The user control is included in aspx page. The user control has two dropdown lists. The second list is getting populated depends upon the selected value from first list. This is done by using Atlas. The UpdateControl is added into this page. The Script manager is added in aspx page.

If the application is launched on the machine where Atlas is installed, it works only on that machine in both browsers (IE and FireFox). It is not working if anybody accesses this website remotely through browser from machine where Atlas is not installed.

If the application is launched on the machine where Atlas is not installed and accessed the local website through browser, the "SelectedIndexChanged" event is not getting triggered. If I add "ScriptLibrary" folder in the application, it is working in FireFox but not in IE. In this case,do I need to add any assemblies apart from Atlas.dll to make it work in IE and without installing Atlas?

Thanks in advance,

Milind

hello. the atlas dll is the only thing you need to have in your bin folder to get the updatepanel working. btw, how are you accessing the web site from the machine that has the app installed? are you using localhost/... or localhost: portnumber/... (ie, are you using the internal server or IIS when you access the site on the server?)


Hello,
I am accessing localhost using IIS.
On the test machine (where Atlas is not installed), if I deploy website application which has Atlas.dll and ScriptLibrary folder, "SelectedIndexChanged" event is getting triggered for FireFox but not in IE.

Thanks,
Milind

hello again.

weird stuff...btw, is this a public url we can see?

Wednesday, March 21, 2012

Writing first extender control

Hi,

I am writing my first extender control to populate a text box with some value on click event of button. But I am missing something hence the extendercontrol is not gettting instanitated and also inserting debugger doesn't break into it. Can someone please help here?

Here is the code:

JS:


Type.registerNamespace('Toolkit');

Toolkit.DisableButtonBehavior = function(element) {
Toolkit.DisableButtonBehavior.initializeBase(this, [element]);
this._button = null;
this._textBox1 = null;
}

Toolkit.DisableButtonBehavior.prototype = {
initialize : function() {
/// <summary>
/// Initialize the behavior
/// </summary>
debugger;
this._button = this.get_element();
Toolkit.DisableButtonBehavior.callBaseMethod(this, 'initialize');
this._clickHandler = Function.createDelegate(this, this._onClick);
$addHandler(this._button, "click", this._clickHandler);
this._AlertHeader();
},

dispose : function() {
/// <summary>
/// Dispose the behavior
/// </summary>
Toolkit.DisableButtonBehavior.callBaseMethod(this, 'dispose');
},

_onClick : function() {
this._AlertHeader();
},

get_TextBox1 : function() {
return this._textBox1;
},
set_TextBox1 : function(value) {
debugger;
this._textBox1 = value;
},
_AlertHeader : function () {
this._textBox1.value = 'test5';
}
}

Toolkit.DisableButtonBehavior.registerClass('Toolkit.DisableButtonBehavior', AjaxControlToolkit.BehaviorBase);


if( Sys && Sys.Application ){
Sys.Application.notifyScriptLoaded();
}

Extender Class:

using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.ComponentModel;
using System.ComponentModel.Design;
using AjaxControlToolkit;

[assembly: System.Web.UI.WebResource("Toolkit.DisableButtonExtender.DisableButtonBehavior.js", "text/javascript")]

namespace Toolkit
{
[ClientScriptResource("Toolkit.DisableButtonBehavior", "Toolkit.DisableButtonExtender.DisableButtonBehavior.js")]
[TargetControlType(typeof(Control))]
public class DisableButtonExtender : ExtenderControlBase
{
[IDReferenceProperty(typeof(Control))]
[DefaultValue("")]
[ExtenderControlProperty]
[ElementReference()]
public string TextBox1
{
get { return GetPropertyValue("TextBox1", ""); }
set { SetPropertyValue("TextBox1", value); }
}
}
}

ASPX:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Testpage.aspx.cs" Inherits="Testpage" %>
<%@dotnet.itags.org. Register Assembly="Toolkit" Namespace="Toolkit" TagPrefix="toolkit" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<asp:ScriptManager ID="scriptmanager" runat="server"></asp:ScriptManager>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button"/>

</div>
</form>
<toolkit:DisableButtonExtender ID="DisableButtonExtender" runat="server" TargetControlID="Button1" TextBox1="TextBox1"></toolkit:DisableButtonExtender>
</body>
</html>

Thanks

Hi,

The only problem I can find in your code is that the ScriptManager and the Extender are placed out of the form. When I modified this and run, it worked fine.

I created a ClassLibrary project, then added the following code into it:

using System;using System.Web.UI.WebControls;using System.Web.UI;using System.ComponentModel;using System.ComponentModel.Design;using AjaxControlToolkit;[assembly: System.Web.UI.WebResource("ClassLibrary1.DisableButtonBehavior.js","text/javascript")]namespace Toolkit{ [ClientScriptResource("ClassLibrary1.DisableButtonBehavior","ClassLibrary1.DisableButtonBehavior.js")] [TargetControlType(typeof(Control))]public class DisableButtonExtender : ExtenderControlBase { [IDReferenceProperty(typeof(Control))] [DefaultValue("")] [ExtenderControlProperty] [ElementReference()]public string TextBox1 {get {return GetPropertyValue("TextBox1",""); }set { SetPropertyValue("TextBox1",value); } } }}

This js file is set as EmbededResources

Type.registerNamespace('ClassLibrary1');ClassLibrary1.DisableButtonBehavior = function(element) { ClassLibrary1.DisableButtonBehavior.initializeBase(this, [element]); this._button = null; this._textBox1 = null;}ClassLibrary1.DisableButtonBehavior.prototype = { initialize : function() { /// <summary> /// Initialize the behavior /// </summary> debugger; this._button = this.get_element(); ClassLibrary1.DisableButtonBehavior.callBaseMethod(this, 'initialize'); this._clickHandler = Function.createDelegate(this, this._onClick); $addHandler(this._button, "click", this._clickHandler); this._AlertHeader(); }, dispose : function() { /// <summary> /// Dispose the behavior /// </summary> ClassLibrary1.DisableButtonBehavior.callBaseMethod(this, 'dispose'); }, _onClick : function() { this._AlertHeader(); }, get_TextBox1 : function() { return this._textBox1; }, set_TextBox1 : function(value) { debugger; this._textBox1 = value; }, _AlertHeader : function () { this._textBox1.value = 'test5'; }}ClassLibrary1.DisableButtonBehavior.registerClass('ClassLibrary1.DisableButtonBehavior', AjaxControlToolkit.BehaviorBase); if( Sys && Sys.Application ){ Sys.Application.notifyScriptLoaded();}

Then used the following page to test it and it worked fine:

<%@. Page Language="C#" %><%@. Register Namespace="Toolkit" Assembly="ClassLibrary1" TagPrefix="toolkit" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="scriptmanager" runat="server"></asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Button"/> <toolkit:DisableButtonExtender ID="DisableButtonExtender" runat="server" TargetControlID="Button1" TextBox1="TextBox1"></toolkit:DisableButtonExtender> </div> </form> </body></html>

Thanks Raymond. Getting script manager within form tag worked.