Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Monday, March 26, 2012

detect when updatepanel has returned in javascript

Hi

I have this code which detects when an updatepanel has returned

Sys.Application.load.add( onLoad );

function

onLoad()

{

var page = $object("_PageRequestManager");

page.propertyChanged.add( changed );

}

function

changed( obj,args )

{

if (args.get_propertyName() && obj.get_inPostBack() ==false)

{

var mode = document.getElementById('<%=siteMode.ClientID %>');//so something

}

}

Is there anyway to tell if a specific update panel was activated on a particular postback and then do something when it has finished its callback.

thanks

andrea

Have you found a solution? I am also looking for the solution, and want to add one more sample here so maybe someone experienced can help (I found the code somewhere (maybe on this forum) and slightly extended it):

<%@. Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void h(object s, EventArgs a) {txt.Text = DateTime.Now.ToString();}void h1(object s, EventArgs a) {txt1.Text = DateTime.Now.ToString();}</script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <atlas:ScriptManager runat="server" id="manager" EnablePartialRendering="true"></atlas:ScriptManager> <atlas:UpdatePanel runat="server" ID="panel"> <ContentTemplate> <asp:Literal runat="server" ID="txt" /> <asp:Button runat="server" ID="bt" OnClick="h" Text="try" /> </ContentTemplate> </atlas:UpdatePanel> <atlas:UpdatePanel runat="server" ID="pane2"> <ContentTemplate> <asp:Literal runat="server" ID="txt1" /> <asp:Button runat="server" ID="bt1" OnClick="h1" Text="try1" /> </ContentTemplate> </atlas:UpdatePanel> </form> <script type="text/javascript"> Sys.Application.load.add( onLoad );function onLoad() {var page = $object("_PageRequestManager"); page.propertyChanged.add( changed );}function changed( obj, args ) {if( args.get_propertyName() == "inPostBack" && obj.get_inPostBack() == false) {alert("refreshed" ); }}</script> </body> </html>

Extending my previous post:

so hove in javascript function "changed" we can know what update panel: panel on pane2 caused call of the javascript function?


Hi

I still havent found a solution either

andrea


Hi,

unfortunately there isn't a solution at the moment. Actually, the ID of the panel that triggered the async postback is contained in the _postbackSettings object of the PageRequestManager, but this is an object that cannot be accessed from outside.

Thus, the only possibility is to modify the source code and create a property that returns the _postbackSettings object. I hope that the team will do this in one of the next releases.

No answer, but possibly related posts have been compiled near the end of this...

http://forums.asp.net/AddPost.aspx?PostID=1373674


hi

that link takes me to a page for adding a new post

thanks


ah, so it does...perhaps this is better...

http://forums.asp.net/thread/1356742.aspx

Wednesday, March 21, 2012

delete ajax Extender with Javascript

hi

I have a problem with AutoCompleteExtender.

the code in HTML

<tr id="trUserName">
<td>
<asp:TextBox runat="server" id="txtUserName" />
<ajax:AutoCompleteExtender id="aceUserName" runat="server" TargetControlId="txtUserName"..... />
</td>
</tr>

when I run script below, it has errors.

var node = document.getElementById('trUserName');
node.parentNode.removeChild(node);

I have tried, if <tr /> tag without any Extender Control, it can be removed.

and I have to remove control in javascript.

Can you help me ?

Hi Benelf,

I think the best way for your situation is put them inside a div container. When you want to delete it, you can hide the div. For example,

<tr id="trUserName">
<td>

<div id="automCompleteContainer">
<asp:TextBox runat="server" id="txtUserName" />
<ajax:AutoCompleteExtender id="aceUserName" runat="server" TargetControlId="txtUserName"..... />

</div>
</td>
</tr>

To hide it , you can do it like this. document.all.automCompleteContainer.style.display ="none";

If you insist on deleting them, I suggest that you should first dispose() the AutoCompleteExtender by using $find("AutoCompleteExtender's BehavoirID").dispose().

I hope this help.

Best regards,

Jonathan

Define DropZones with DragOverlayExtender

Hi

I'm using the DragOverlayExtender to create a draggable UI (like live.com).
How can I define some fix drop-zones? So dragged objects should only drop there.

Tank you.

Hi,

I've just postedan article on my blog about drag&drop in Atlas, that includes an example of a draggable UI. Hope it helps.
Thx - this seems to be exactly what I was looking for!

But how can I add a control-section at runtime?

<control id="content1">
<behaviors>
<draggableListItem handle="content1Handle"
dataType="HTML" />
</behaviors>
</control>

I found that this works with

IScriptControl ctrl =
ScriptManager.GetCurrent(this).RegisterControl(myControl);

Then on ctrl there is a Method called RegisterBehaviour, but how can I use this. The method needs an IScriptBehavior-Implementation - so how can I use the draggableListItem-Behavior for this?
Hi,

Following the Atlas philosophy, the suggested approach (server-centric) would be that of creatingextenders for drop zones and draggable panels. Basically you have to derive a class fromExtenderControl and a class fromTargetControlProperties. Then, override theRenderScript() method of theExtenderControl class to render the Atlas markup.

Checkthis blog entry byNikhil Kotari orthis one from my Atlas blog, for some info about extenders.
Hi,

well, what I wrote above is not 100% correct, since anextender is supposed to extend an existing ASP.NET control or maybe acustom ASP.NET control. What you could do is build an Atlas-enabledserver control, rendering both the HTML and the Atlas markup.

Checkthis blog entry and look at the section "Support for Atlas-Enabled Server Controls" for some info.
Hey

So your second post is the way I tried... but I have still the problem that I mentioned. The number of controls that are draggable is not known at designtime, so I'd like to insert the DnD-behaviors for the different controls at runtime.

The follow method seems to be the one - but I don't know how to implement:
Microsoft.Web.Script.IScriptControl c =
ScriptManager.GetCurrent(this).RegisterControl(myControl);
c.RegisterBehavior(xxx);

So the 3x should be an IScriptBehavior-Implementation. In the declarative Way, I used
<control id="CVPart">
<behaviors>
<draggableListItem handle="CVPartTitle" dataType="HTML" />
</behaviors>
</control
So what do I have to do, to register this behavior (draggableListItem) at runtime.
OK... I found a quite simple solution... :-)

I've just created a new class that implements IScriptBehavior (and IScriptObject).
In the RenderScript-Method I just create the <draggableListItemhandle="myControl" type="HTML" /> with the ScriptTextWriter...

3 Lines of code... one day is over :-D
Thank you!

Hello! Could you please send me an example of your code?

Just to not waste the whole day for 3 lines of code ;)

Thank you!

DefaultButton and DefaultFocus

Hi

I have a code, when i use DefaultButton and DefaultFocus.

When i put UpdatePanel to the Page, DefaultButton and DefaultFocus work only on first load of page. After callback it is dosn't work. Anybody know where is the problem?

Btw. I use MasterPage in this code then i set DefaultButton and DefaultFocus in PageLoad

Page.Form.DefaultButton = this.Button1.UniqueId;

Hi,

I also faced the same issue. I think the asp.net provided default button has some issue regarding this

I worked with BinaryIntellect DefaultButton server controls which works as expected. You may try it from here: http://www.binaryintellect.com/products

Cheers,
Murugan.G

I encounted the same problem before, Finally, I put me.textbox1.focus in Page_Load, that OK, you may try it.