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

Wednesday, March 28, 2012

Line 5909 Javascript Error

Error Message:

Line:5909
Char:12
Error: Sys.ArgumnetUndefinedException:Value cannot be undefined. Parameter name:id

Code:

I write an mask customer validator control And use this control in ajax updatepanel control. It will show javascript error.

Below is my code:

maskedVad.ClientValidationFunction = this._CallbackFailFunction;
vce4Mask = new ValidatorCallbackExtender();
vce4Mask.TargetControlID = maskedVad.ID;
vce4Mask.HighlightCssClass = this._HighlightCssClass;
vce4Mask.CallbackFailFunction = this._CallbackFailFunction;
vce4Mask.CallbackControlID = this.ID;
Controls.Add(vce4Mask);

This is apparently a bug in the Ajax RTM that will be fixed. In the meantime you should check out this link for a solution:
http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx


I replaced validators.js file and added the tagmapping in web.config. but the bug still existed. Can someone give me more suggestions?


Hi Wallance,

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Best Regards,

Jonathan


I do a custom extendtextbox webcontrol.

TextBox txt = new TextBox()

req = new RequiredFieldValidator();
req.ControlToValidate = this.ID;
req.ID = this.ID + "_req";
req.Display = ValidatorDisplay.None;
string sRoot = HttpContext.Current.Request.ApplicationPath;
req.ErrorMessage = this.RequiredErrorMsg;
req.EnableClientScript = (this.ClientScript.ToLower() != "false");
Controls.Add(req);

vce4Required = new ValidatorCallbackExtender();
vce4Required.TargetControlID = req.ID;
vce4Required.HighlightCssClass = this._HighlightCssClass;
vce4Required.CallbackFailFunction = this._CallbackFailFunction;
vce4Required.CallbackControlID = this.ID;

See the aspx

<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<contenttemplate>

<asp:Table runat="server" id="appInfoTable">
</asp:Table>

</contenttemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnadd" EventName="Click" />
</Triggers>


</asp:UpdatePanel>

addbtn_click

protected void CreateRows(int Rowcount)
{
int i = 0;
for (i = 0; i < Rowcount; i++)
{
TableRow tr = new TableRow();

TableCell tc = new TableCell();
extendtextbox txt = CreateTextBox(i);
tc.Controls.Add(txt);

tr.Cells.Add(tc);
appInfoTable.Rows.Add(tr);
}
}

private extendtextbox CreateTextBox(int loop)
{
extendtextbox txtbox = new extendtextbox ();
txtbox.Validate = "required";

txtbox.ID = "mytextbox" + loop.ToString();
txtbox.Label = "acc_accountInfoForm_label_loginInfo";
txtbox.RequiredErrorMsg = "only for test";
txtbox.Type = extendtextbox .Text;
return txtbox;
}

Because the code is very long. Include one webcontrol and one page.

Thank you very much.


Hi Wallance,

Please add break point at "req = new RequiredFieldValidator(); req.ControlToValidate = this.ID;" and debug it step-by-step since the error propmt is "Sys.ArgumnetUndefinedException:Value cannot be undefined. Parameter name:id". Thanks.

Best Regards,

Jonathan.

Links dont work properly in a working Modal Popup

Is it possible to have client side <a href links inside an extender?

I've got a Modal Popup working. A webservice is invoke via javascript on the client. The webservice queries a database and returns html to the javascript which inserts the markup into the Modal Popup panel. The popup works well, displaying a title, a description and an image. It also displays a <a href link, however this link doesn't work as intended. It displays as a link but when clicked goes nowhere. I've tried it with and without target="_blank". The only way make it function is by right clicking on it and Opening in a new tab or in a new window. Any advice would be very welcome as I'm stuck and it's far from user friendly in it's current state.

Hi oscar,

Do you got some code that replicates the error?

Kind regards,
Wim


Hello,

What is resulting output of the link?

Thanks,

Louis


Thanks both for taking the time to help out. I tried logging in to reply, entered my password incorrectly once and my user account has now been locked out, despite it letting me reset my password.

I've now got this working.

The web service returns a string containing all of the markup to be displayed in the panel:

strdetails += "<a href="http://links.10026.com/?link="""onClick=""javascript:popUp('"
strdetails += ds.Tables(0).Rows(0)("livemaplink").ToString()
strdetails += "')"">Live Map</a>"

then with the rest of the javascript functions in the aspx page is this:

function popUp(URL)

{window.open(URL);}

I'd tried adding the popup function to the panel in the strdetails string and it didn't work but this does.

Thanks again.


Hi oscar Version 2Stick out tongue

Glad you got it to work!

Euhm, Even if none of our answer are actually solutions, I think you can still mark the thread as solved, somewhere on top, or mark your reply as answer. Because this thread is resolved ;)

Kind regards,
Wim


Will do, when my original account is unlocked that is!Big Smile

Cheers.


Will do, when my original account is unlocked that is!Big Smile

Cheers.

List<object> from ASP .NET to javascript

Hi,

I would like to know if it is possible to use List<object> as parameter in an AjaxExtender??

[ExtenderControlProperty]
[DefaultValue("")]
public List<object> HandlerFieldList
{
get {return GetPropertyValue<object>>("HandlerFieldList",null); }
set { SetPropertyValue<object>>("HandlerFieldList",value); }
}
<cc2:AjaxControl4WebGridExtender ID="AjaxControl4WebGridExtender1" runat="server"
TargetControlID="GenericTimeGrid1"
TargetID="GenericTimeGrid1" ServiceMethod="executeCommand" HandlerFieldList="argList">

By trying these I get the following error:

 Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Cannot create an object of type 'System.Collections.Generic.List`1[[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' from its string representation 'argList' for the 'HandlerFieldList' property.

perhaps should I say: the argList is defined in Default.aspx.cs and field also there in Page_Load()

regards Omid

Is that linst object is in the UpdatePanel ??

Idea


no it is not... aren't there some TypeConverter for it in ASP .NET oder the Ajax Toolkit...?

I think I have to write an converter for it..

Monday, March 26, 2012

Listeners Broadcast in Javascript/ Atlas Library

Is there a framework in place for a Atlas JS Control to raise an eventwhich can have other Controls or global functions listen in on andhandle?

Just like in Web User Control, we can raise Events which can be handledby pages or other controls that 'listens' in on the event, can the samebe accomlished in JS?

The Web User Control shouldnt know who has registered to listen in onthe event but somehow the Control has to communicate that something hashappened.Would any of the below code help in what I want to accomplish?Basically different components can listen in or another componentsevents, and when that event is raised, each of the listeners methodsare invoked?


Type.createEnum('Sys.ActionSequence','BeforeEventHandler', 0,'AfterEventHandler', 1);
Sys.IAction = function() {
this.get_sequence = Function.abstractMethod;
this.execute = Function.abstractMethod;
this.setOwner = Function.abstractMethod;
}
Sys.IAction.registerInterface('Sys.IAction');

Type.Event = function(owner, autoInvoke) {
var _owner = owner;
var _handlers =null;
var _actions =null;
var _autoInvoke = autoInvoke;
var _invoked =false;

this.get_autoInvoke = function() {
return _autoInvoke;
}

this._getActions = function() {
if (_actions && _actions.length && !_owner)throw"Actions are only supported on events that have an owner.";
if (_actions ==null) {
_actions = [];
}
return _actions;
}
this._getHandlers = function() {
if (_handlers ==null) {
_handlers = [];
}
return _handlers;
}
this._getOwner = function() {
return _owner;
}

this.isActive = function() {
return ((_handlers !=null) && (_handlers.length != 0)) ||
((_actions !=null) && (_actions.length != 0));
}

this.get_isInvoked = function() {
return _invoked;
}

this.dispose = function() {
if (_handlers) {
for (var h = _handlers.length - 1; h >= 0; h--) {
_handlers[h] =null;
}
_handlers =null;
}
if (_actions) {
for (var i = _actions.length - 1; i >= 0; i--) {
_actions[i].dispose();
}
_actions =null;
}

_owner =null;
}

this._setInvoked = function(value) {
_invoked =true;
}
}
Type.Event.registerSealedClass('Type.Event',null, Sys.IDisposable);

Type.Event.prototype.add = function(handler) {
this._getHandlers().add(handler);
if (this.get_autoInvoke() &&this.get_isInvoked()) {
handler(this._getOwner(),null);
}
}
Type.Event.prototype.addAction = function(action) {
action.setOwner(this._getOwner());
this._getActions().add(action);
}
Type.Event.prototype.remove = function(handler) {
this._getHandlers().remove(handler);
}
Type.Event.prototype.removeAction = function(action) {
action.dispose();
this._getActions().remove(action);
}
Type.Event.prototype.invoke = function(sender, eventArgs) {
if (this.isActive()) {
var actions =this._getActions();
var handlers =this._getHandlers();
var hasPostActions =false;
var i;

for (i = 0; i < actions.length; i++) {
if (actions[i].get_sequence() == Sys.ActionSequence.BeforeEventHandler) {
actions[i].execute(sender, eventArgs);
}
else {
hasPostActions =true;
}
}

for (i = 0; i < handlers.length; i++) {
handlers[i](sender, eventArgs);
}

if (hasPostActions) {
for (i = 0; i < actions.length; i++) {
if (actions[i].get_sequence() == Sys.ActionSequence.AfterEventHandler) {
actions[i].execute(sender, eventArgs);
}
}
}

this._setInvoked();
}
}


Sorry for the message, I forgot to check the Atlas Client sidereference library where it has a nice page on this:http://atlas.asp.net/docs/Client/Type/Event/default.aspx

but anyone with more concrete examples would be much appreciated :)
Hi,

the Atlas framework gives you the ability to declare multiple handlers for an event. Just use the add() method on the exposed event to add a handler.

For example, if the instance myObject exposes a myevent event, you can write a statement like:

myObject.myevent.add(myMethod);

to register a handler for that event.
Thanks for your response Garbin (+ props to your weblog)

Looking at your pager example:

// Events.
// The Pager exposes the pageChanged event, which is raised
// when the page index to be displayed changes.
this.pageChanged =this.createEvent();
...

Which exposes a pageChanged property where I can pass in one method on the initialization of the Atlas Control.

td.addEvent('pageChanged',true);

...

The event is raised by:

this.pageChanged.invoke(this,new AtlasNotes.PagerEventArgs(_pageIndex, _pageSize, _totalRecords));

so going by your post, I can append more methods to be handled by going:

myObject.pageChanged.add(myMethod);

If so, Ill try it on Monday :D


The above code works beautifully :)

Listening to a CascadingDropDown event. How?

Is there any way to call client-side javascript when the CascadingDropDown has successfully finished its population from a webservice? Please give a code sample.

The solution and code sample is availablehere (provided bychrispont. Thanks,chrispont!).

ListSearchExtender could work much better with slight enhancement

The List Search Extender is definitely very useful but a slight enhancement could make it a lot better. I use a javascript implementation of this type of functionality in my code which can be seen at:

http://www.codeproject.com/useritems/selectasyoutype.asp

The key difference is the following. Say as an example you have a long list of names in a listbox e.g. list of countries. You start typing 'i' 't' 'a' for Italy. Now you can change your mind and actually want to go for Spain so you next type in a 's' and then 'p' etc. Where the Select As You Type script differs is that when it doesn't find any matches for 'i' 't' 'a' 's' 'p', it starts again at the point where you started a new search. So instead of the listbox looking for 'itasp', it actually realises that it should now be looking for countries starting with 'sp'. Could you guys possibly implement that as it is far better than having to erase each of the characters to start the listbox search again.

Regards

Harel

This is an interesting idea -- I've created a work item for it. If anyone else would like this functionality then please vote for it:http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=8763

Regards,

Damian


There would need to be some type of timeout attached to the control so if a user stopped typing for X seconds and started again, the control would realize that a new sequence of characters was being typed. Explorer.exe contains that functionality, of course.

I definitely vote yes for it.

Saturday, March 24, 2012

Load a javascript file in an updatepanel

Ipresent the context to you. I have a project principal compound of anupdatepanel. When I click on a button, I filled my updatepanel with a"templatd control". This one appears well. This control haves embeddes resources (images + Javascript file). My problem is that my control charges only the images and not my Javascript file. When I use this control in a simple page, it works correctly. I think that it is impossible to charge a fileJavascript in a updatepanel. What do you think about it? Thank you inadvance for your answers.

Damien

Damien,

Personally what I would do as UpdatePanel makes a server request to do your processing in the postback server side, easier and cleaner, you already in the server, then why not. Putting javascript with the UpdatePanel, why? the UpdatePanel is to go to the server without the user to see the request, then just use that!

Makes sense?

Load atlas js resource before charging page

Hi

Is it possible to load all Atlas resources on client before charging a page using Atlas ?
In fact, using Atlas means getting big javascript resources (near 300 ko for a page using webservice and updatepanel both).

My ideas is to :
- Load Atlas resources (with a loading message)
- And after load the page using Atlas

Thanks for your help.
ClémentM

hello.

well, the loading time should only hit you the 1st time the atlas files are loaded (they should be cached for future calls).

you can, however, show a loading msg. to dismiss it, you can handle the load event of the sys.application object.

Load in-line javascript functions after UpdatePanel refresh

I have a lot of user controls that have in-line javascript functions specific to the content of the user control, validations and automated reactions. This javascript is written mostly by client side developers. Is there any way to allow them to keep writting their in-line javascript on the user controls, but still have that javascript be active after an updatepanel conditionally makes the user control visible? For example imagine a page with a button and the user control. The user control is in an update panel tiggered by the button click. When clicked the user control has its visibility set to true and the user interacts with the newly visible controls contained within. Because the user control was initially in an update panel, the original page source does not contain the in-line javascript functions so they are never evaluated by the browser. In order to keep the client side group's functionali i've had to recreate the client side code on the server side by building a large string that references controls using the control.ClientID property (just like the client side group does with inline scriplets $get(<%= control.ClientId %>) and then registering this string on the page with ScriptManager. This is too inefficient a process and having the javascript placed on every page that uses the user control seems counter productive with regard to user controls. Placing all the javascript in external files that get loaded by ScriptManager is also not an option as the javascript is often control specfic. Is there no way to get the browser to recognise the in-line javascript after an update panel loads it? Is this something that is planned for the future if not?

Well, I don't know if it is the final solution, but I figured that I could use display:none and display:block on a panel wrapping the user control instead of using the Visible property on the control itself. This way the control (and most importantly the javascript) is initially rendered, but not browser visible. If there is still some way to use the built in Visible property to do what I want, please let me know. I like that the inital page load using the Visible property doesn't have the extra weight of controls that are not usuable.


You can give this approach a try:http://blogs.msdn.com/sburke/archive/2007/06/13/how-to-make-tab-control-panels-load-on-demand.aspx

-Damien


I believe that approach will suffer from the same issue. The tabcontainer content will not be initially visible and so any inline javascript contained in a tabcontainer will not be evaluated by the browser.


Sorry about that I miss read your question. If the JS is embedded in the usercontrols they need to be loaded, so your solution works. I'm a bit confused why you need the JS loaded if they are control specific. Sounds like there may be a design problem with your solution.

-Damien

load page in div using ajax --> ajax functionality lost :s

Hi all,

I found some javascript on the net to load a page in a div. Now the problem is that the loading of the page in the div works, but then when I use ajax-functionality in the page loaded in the div, the page just refreshes.

Here I found the code:http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

Here is a simular thread (his issue got resolved but mine not. On his site things seem to work just fine :s):http://forums.asp.net/t/1163067.aspx

Here is my working demo showing what goes wrong:

This is my situation:

    I have 2 pages: Default and Content.Default loads Content on it's page (using the "loading a page in a div"-logic)Content has basic ajax functionality which works from Content itself.Content's ajax func. won't work when it's loaded on Default.
The Default.aspx page (no codebehind to keep it simple):
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false"%><!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>Default</title><script type="text/javascript">var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)var loadedobjects=""var rootdomain="http://"+window.location.hostnamevar loadstatustext="<img src='img/loading.gif' /> Requesting content..."function ajaxpage(url, containerid){var page_request = falseif (window.XMLHttpRequest) // if Mozilla, Safari etcpage_request = new XMLHttpRequest()else if (window.ActiveXObject){ // if IEtry {page_request = new ActiveXObject("Msxml2.XMLHTTP")} catch (e){try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}}elsereturn falsepage_request.onreadystatechange=function(){loadpage(page_request, containerid)}page_request.open('GET', url, true)page_request.send(null)}function loadpage(page_request, containerid){if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))document.getElementById(containerid).innerHTML=page_request.responseText}function loadobjs(){if (!document.getElementById)returnfor (i=0; i<arguments.length; i++){var file=arguments[i]var fileref=""if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceedingif (file.indexOf(".js")!=-1){ //If object is a js filefileref=document.createElement('script')fileref.setAttribute("type","text/javascript");fileref.setAttribute("src", file);}else if (file.indexOf(".css")!=-1){ //If object is a css filefileref=document.createElement("link")fileref.setAttribute("rel", "stylesheet");fileref.setAttribute("type", "text/css");fileref.setAttribute("href", file);}}if (fileref!=""){document.getElementsByTagName("head").item(0).appendChild(fileref)loadedobjects+=file+" " //Remember this object as being already added to page}}}
</script></head><body> <form id="form1" runat="server"> </form> <p> <a href="javascript:ajaxpage('Content.aspx', 'contentarea');">test</a> </p><div id="contentarea"></div></body></html>

The Content.aspx page (also no codebehind to keep it simple):

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" %><script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadMe.Label1.Text = DateTime.Now.ToString End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)Me.Label1.Text = DateTime.Now.ToString End Sub</script><%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><!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>Content</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div><asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate><asp:Label ID="Label1" runat="server" Text="" Width="138px"></asp:Label><br /><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate></asp:UpdatePanel> </div> </form></body></html>

Could anyone please give it a try? I don't know what's going on.
The code above should work! Just make the 2 pages and copy the entire code into it.Thanks!

Kind regards,
Wim

My guess would be that your Content.aspx page contains some sort of window.onload event-handler to wire-up the Ajax stuff, but when you load in Content.aspx into Default.aspx using Ajax its window.onload event will not fire (the window.onload event will already have fired when Default.aspx was loaded).


ijoxley:

My guess would be that your Content.aspx page contains some sort of window.onload event-handler to wire-up the Ajax stuff, but when you load in Content.aspx into Default.aspx using Ajax its window.onload event will not fire (the window.onload event will already have fired when Default.aspx was loaded).

Hi ijoxley,

Thanks for your reply ...

But when I look at my code that's posted above, I don't see anything unusual happening in any onload event.


deblendewim:

But when I look at my code that's posted above, I don't see anything unusual happening in any onload event.

That's true - but its probably hidden away somewhere in the JavaScript generated by the ScriptManager tag.

It might be an idea to add a ScriptManager to the Default.aspx page then writing some JavaScript to handle the DOMNodeInserted event (for when you load Content.aspx into your <div> tag).


Anyone?


hello.i'm not sure on what you're trying to do here, but the approach you're using isnot the best to use if you're using asp.net ajax. ok, regarding your problem, i agree with the previous answeres you've received: the client portion of the asp.net ajax platform needs to run several pieces of code during the load event of the page. when you load a page like that, you're not getting that event and this means that your updatepanel won't be ready for patial postbacks.in my opinion, you should use only one page and if you need to change the contents of the page, then you can use one or more usercontrols to achieve that (instead of having several pages that are loaded into the center of your main page).

Wednesday, March 21, 2012

Load UserControl After PageLoad is completed

I'm still pretty new to the ajax / javascript scene, so I'm finding myself stumped on what may be a very simple thing. If anybody can point me in the right direction, I will be very grateful.

What I have is this:

I have a user control that has an update panel wrapped around a listview control that gets data from a data source.

I have a page that has the user control on it.

What I want to happen is for the page to load then the user control to go get its data and refresh the listview. Something like pageflakes. Where the page loads while the widgets are updating themselves, except in this case it will be a user control updating.

Is this possible? If so, can somebody point me in the right direction?

Thanks in advance!!

Kendra

http://mattberseth.com/blog/2007/07/delay_load_an_updatepanel.html

http://mattberseth.com/blog/2007/06/aspnet_ajax_canceling_an_async_1.html


Thank you thank you thank you... i have read tons of Matt's articles and hadn't run across this one yet. Of course, using the right search term helps as well.

Localized Calendar

I need use a localized version of CalendarExtender, but it's not possible to change the format of today because the javascript function _performLayout set this._today.innerHTML = "Today: " + todaysDate.format("MMMM d, yyyy");

Yes, it's easy replace this line, but all the contents are localized, why not this??

Hi there will be a fix for this in the next realease of the control toolkit due 28 feb.

This has been reported as workitem 7577 more info onhttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7577

More info about bug fixes in the 10228 release can be found herehttp://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=1425

Hope this helps!