Showing posts with label define. Show all posts
Showing posts with label define. Show all posts

Wednesday, March 21, 2012

Defining 2nd Autocomplete Textbox

How would you define a second autocomplete textbox? Below is how I did it and I have two seperate div tags for the drop downs.
Seems like the memory isn't cleared or something like that because the second drop always seems to call the first drop downs method or at least produce a list as if it called the first drop downs method.

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<references>
<add src="ScriptLibrary/AtlasUI.js" />
<add src="ScriptLibrary/AtlasControls.js" />
</references>
<components>
<textBox id="SearchKey">
<behaviors>
<autoComplete
completionList="completionList"
serviceURL="AutoCompleteService.asmx"
serviceMethod="GetWordList1"
minimumPrefixLength="2"
completionSetCount="15"
completionInterval="500" />
</behaviors>
</textBox>

<textBox id="SearchKey1">
<behaviors>
<autoComplete
completionList="completionList1"
serviceURL="AutoCompleteService.asmx"
serviceMethod="GetAppList"
minimumPrefixLength="2"
completionSetCount="15"
completionInterval="500" />
</behaviors>
</textBox>
</components>

</page>

</script>
Thanks for any help,
Clank

On top in the Web Service code, find this line..

privatestaticstring[] autoCompleteWordList =null;


I guess u must be storing the 2nd result also in this same member. Change this to

privatestring[] autoCompleteWordList =null;

It should work now.
Thanks, that fixed my problem.

Define itemTemplate for Reorderlist at runtime

Hi,

I am able to get the reorderlist control to work my supplying a datasource and writing the markup for the itemTemplate.

How do i go about setting the itemTemplate at runtime depending on the datasource?

I tried programatically creating ReorderListItems, and collections but nothing got rendered.

I see that the ReorderList has an itemTemplate property, will this help?

OK. I have figured it out how to do it by creating a class that implements the ITemplate interface.

The problem i have now is i am using the reorderlist control within the accordian control.

For example i have a menu with 3 selections. This is controlled by the accordian.

Within the each accordian pane, i create a reorderlist, therefore there are 3 reorderlists, one within each accordian pane. This works fine, and i am able to reorder the items in the list. However, it seems that when i try to move items in the 2nd/3rd pane, they all disappear into the 1st pane. Is this because even though it looks like the accordian is shrinking and expanding, the actual working area for the reorder list is already defined, hence when pane 1 is minimised with pane 2 open, pane 2 reorderlist is actually already ontop of pane 1 reorder list??

I hope the above makes sense.

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!

Define a PageMethod in a MasterPage

I have a web site that uses Master/Content pages and I have a PageMethod that I would like to make available to a any of the content pages. So I defined the method like I would in a Content Page:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Text;

using System.Web;

using System.Web.Security;

using System.Web.Services;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Web.Configuration;

publicpartialclassMasterPage : System.Web.UI.MasterPage

{

[WebMethod]

publicstaticstring MyMethod()

{

//Some Code Here

}

}

And I already have my script manager setup on the master page as follows, which works for all my PageMethod calls from Content Pages:

<asp:ScriptManagerID="masterPageScriptManager"runat="server"EnablePageMethods="true"EnablePartialRendering="true">

</asp:ScriptManager>

However, when I try to call PageMethods.MyMethod(MyMethodCompleteHandler); I get our favorite error, "PageMethods is Undefined." Is it possible to define a PageMethod in a MasterPage like this. If so what am I missing?

Thanks

Patrick

To be able to invoke that MyMethod

you need first to cast the MasterPage property of a page to your class (MasterPage) and then invoke it.

So if it was in the code behind of a content page to be able to invoke it you should write sth like :

string result = ((MasterPage)this.MasterPage).MyMethod();



Yani, I think he's talking about fromt eh javascript side.

On an unrelated note, mnogo mi obicham Bulgaria! Moja jena e bulgarka i nia otidame tam v sofia za 2-3 cedmitsi prez ljatoto vseki godina.

Paul (my apologies for grammar and spelling)


Hi Paul,

you are right about the javascript.

However, my point was that defined on the master page this static method does not become a page (content page) method. The master page is not a base class for the content pages, moreover it is a static page.

For this case it would be more suitable to create a web service, that will be accessible from everywhere.

Cheers,

Yani

PS: Paul, it is very nice you have learn some Bulgarian :)) Congrats!Wink


To answer the original question, I looked at the response in Fiddler and it looks like the Master page pagemethod doesn't get generated. I'm not yet sure how to work around that, I'll give it some thought.

Patrick,

I believe you won't be able to accomplish what you're trying with PageMethods.

The EnablePageMethods will assume that the method is defined in a.aspx page. This is why it is called a "Page Method".

If you want the method be available to all pages, why not use a simple webservice?

DefaultButton in UpdatePanel

ASP.Net 2.0 has a nice feature. You can - in a panel - define a DefaultButton. When you have focus in a TextBox (on the panel) and presses RETURN, you click the DefaultButon.
When using an UpdatePanel (ScriptManager:EnablePartialRendering="True) this also works fine, but... only once.
Does somebody knows a workaround or a solution or am I doing something wrong?

<atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:PanelID="Panel1"runat="server"DefaultButton="Button1">
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<asp:ButtonID="Button1"runat="server"OnClientClick='alert("click")'Text="Button"/></asp:Panel>
</ContentTemplate>
</atlas:UpdatePanel>

hello.

well, this is a side-effect bug related with the way the code used by the asp.net works. when you add a default button, you get this on your panel:

THe problem happens on the WebForm_firedDefaultButton. Inside, the method checks for a global variable called __defaultFired which initially is set to false. the 1st thing the method does is check the value of this var. if it is set to true, it doesn't do anything since it thinks you're re-submitting the form. if you think only about ASP.NET, this makes sense, right?

unfortunatelly, when yuo use atlas you start getting the behavior you've described. for now, i think that you can override the prerender method of your page and add this:

protected override void OnPreRender (EventArgs args)
{
base.OnPreRender(args);
this.ClientScript.RegisterStartupScript(this.GetType(), "resetBt", "__defaultFired = false;", true);
}

By injecting this instruction, you're resetting the state of the _defaultFired variable so that you're able to start another request when you press the enter key.


btw, what's wrong with the feedback center? i'm trying to add a bug and can't pass from the searh page :(

Thank you for your reply Luis. It works!


Sorry to say but then i am having the same problem and not bale to get it work :(

Can you please help ?

This is a known issue in the current CTP and we are considering fixing it in a future release.

Thanks,

Eilon


the prerender solution doesn't work at my neither :(

maybe it depends on which CTP you're using? are there any other solutions available right now?


protected override void OnPreRender(EventArgs args)
{
base.OnPreRender(args);
this.ClientScript.RegisterStartupScript(this.GetType(), "resetBt", "__defaultFired = false;", true);
}

works in IE but not in Firefox

always working Workaround or Fix would be great


Does anyone have a workaround for this that will work in Firefox? I'd really rather not have to yank out all of my updatepanels, but this is about the only option I see right now.

Thanks


hello.

i really hanve't checked how the current version implements this functionality. i suggest that you use a new static methods of the scriptmanager class instead of using the clientscriptmanager class to register the startup scripts.


Has anyone figured out a way to get the the default button working with firefox in an updatepanel?

Did'nt want to start a new topic!

Thanks


hello.

if i recall correctly, the approach mentioned on this thread doesn't work only in IE (ie, it should work without any problems in firefox)

After struggling with this for a while between browsers andAtlas ajax.net I chose a dumb method and implement this in code, w/o using the DefaultButton attribute. I set this on Page_Load for any control collection. In fact ASP.NET should have a default button setting for just about anything that is clickable - for example the button on an panel extender.

publicstaticvoid SetDefaultButton(WebControl button,ControlCollection cc)
{
foreach (System.Web.UI.Control wcin cc)
{
SetDefaultButton(button, wc.Controls);
if (wcis System.Web.UI.WebControls.WebControl)
{
if (wcis System.Web.UI.WebControls.TextBox)
{
TextBox tb = (TextBox)wc;
SetDefaultButton(button, tb);
}
}}}publicstaticvoid SetDefaultButton(WebControl button,TextBox tb)
{
if (tb.TextMode ==TextBoxMode.MultiLine)
return;

tb.Attributes.Add(

"onkeydown","if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + button.UniqueID +"').click();return false;}} else {return true}; ");
}


The OnPrerender() solution above didn't work for my app.

I had this issue in IE and Firefox.In IE the first time the user pressed enter the default button fired, but after that it won't fire. In FireFox is was just the opposite, the first time it wouldn't fire and then it fired fine after that.

The fix I came up with (after seeing the OnPrerender() exmaple) is to set the __defaultFired variable appropriately in the pageLoad() function which AJAX calls after the page is completely loaded. This works for IE, Firefox and Safari.

<script type="text/javascript" language="javascript">
function pageLoad()
{
if (navigator.userAgent.indexOf("Firefox")!=-1)
{
__defaultFired = true;
}
else
{
__defaultFired = false;
}
}
</script>

I put this on my master page and now all my default buttons fire properly now.

Anyone know why Firefox has the reverse logic for __defaultFired?


I am having the same problem. :( DefaultButton works only in IE, not in Firefox. Can anyone on the Asp.net Ajax team comment on whether this will be fixed for the release version?

Thanks