Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Wednesday, March 28, 2012

How do I put a scrollbar on an AutoComplete extender?

Hi, I'm new to the AJAX toolkit (and AJAX) so I hope you'll forgive me asking this stupid question. I can see from the example website that it is possible to have an AutoComplete extender which if you have more than say ten suggestions, it shows the first ten and then you can scroll through the rest.

However, I can't see which bit of the example code tells it to do that. What I Here's what I've got right now.


<form id="form1" runat="server">
<asp:ScriptManager ID="AutoCompleteScriptManager" runat="server" >
<Services>
<asp:ServiceReference Path="AutoCompleteService.asmx" />
</Services>
</asp:ScriptManager>
<br />
<asp:TextBox ID="TextBox1" runat="server" Columns="40" ></asp:TextBox>

<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender" runat="server" TargetControlID="TextBox1" CompletionInterval="10" MinimumPrefixLength="1" ServicePath="AutoCompleteService.asmx" ServiceMethod="GetCompletionList" >

</ajaxToolkit:AutoCompleteExtender>
</form

I'd appreciate it if somebody could point me in the right direction. Thanks.

Just thought I'd bump this thread as it had gone off the front page. I'd really appreciate some help with this.


You need to use an appropriate CSS class with overflow:auto on the appropriate elements.

Set a value for CompletionListCssClass to something that controls the CSS correctly. Not being a CSS chap, I leave that exercise to somebody else :)


Hi GillouX,

Here is the sample that we set the AutoComplete's CompletionListElementID to a Panel and then set the css to the panel.

<%@. 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"
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style>
.AutoExtender
{
font-family: Verdana, Helvetica, sans-serif;
font-size: .8em;

font-weight: normal;
border:solid 1px #006699;

line-height:20px;
padding:2px;
background-color:White;
}

.AutoExtenderList
{
border-bottom:dotted 1px #006699;
cursor:pointer;
color:Maroon
}

.AutoExtenderHighlight
{
color:White;
background-color:#006699;
cursor:pointer;
}

</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TBSearch" runat="server"></asp:TextBox>
<asp:Panel runat="server" ID="myPanel" Height="100px" ScrollBars="Vertical">
</asp:Panel>
<ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1" BehaviorID="myACEBID" TargetControlID="TBSearch"
ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="1" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight" CompletionInterval="1" EnableCaching="true" CompletionSetCount="12"CompletionListElementID="myPanel"/>
<br/><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>

WebService

"C#" Class="AutoComplete" %>using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Collections.Generic;[WebService(Namespace ="http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.Web.Script.Services.ScriptService]public class AutoComplete : System.Web.Services.WebService { public AutoComplete() { } [WebMethod] public string[] GetCompletionList(string prefixText, int count, string contextKey) {// contextKey += "23"; if (count == 0) { count = 10; } if (prefixText.Equals("xyz")) {return new string[0]; } Random random =new Random(); List<string> items =new List<string>(count);for (int i = 0; i < count; i++) {char c1 = (char)random.Next(65, 90);char c2 = (char)random.Next(97, 122);char c3 = (char)random.Next(97, 122); items.Add(prefixText + c1 + c2 + c3); }return items.ToArray(); }}

I hope this help.

Best regards,

Jonathan

Monday, March 26, 2012

How do I extend an Atlas extender?

Let's say I create my own Atlas Control Extender. For example, I create an extender called MyHoverExtender. But instead of extending Control or WebControl, I want to extend the HoverMenuExtender. But when I change it to use that, I get this error:

error BC32044: Type argument 'SearchResultItem.MyHoverExtenderProperties' does not inherit from or implement the constraint type 'Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)'.

Can anyone help me with this error?

Thanks

The extender class and the properties class have to travel in pairs. So if you derive from the extender, you need to also do so from the properties class. I think if you just have your MyHoverExtenderProperties class inherit from HoverMenuProperties you should be OK.



So here's what I've got right now:

-----------------

MyHoverExtenderDesigner.vb:

Class MyHoverExtenderDesigner
Inherits Microsoft.AtlasControlExtender.Design.ExtenderControlBaseDesigner(Of MyHoverExtenderProperties, AtlasControlToolkit.HoverMenuExtender)
End Class

Produces this error:

error BC32044: Type argument 'SearchResultItem.MyHoverExtenderProperties' does not inherit from or implement the constraint type 'Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)'.

-----------------

MyHoverExtenderExtender.vb:

<Assembly: System.Web.UI.WebResource("SearchResultItem.MyHoverExtenderBehavior.js", "text/javascript")>

<System.ComponentModel.Designer(GetType(MyHoverExtenderDesigner))> _
<Microsoft.AtlasControlExtender.ClientScriptResource("MyHoverExtender", "MyHoverExtenderBehavior", "SearchResultItem.MyHoverExtenderBehavior.js")> _
Public Class MyHoverExtenderExtender
Inherits Microsoft.AtlasControlExtender.ExtenderControlBase(Of MyHoverExtenderProperties, AtlasControlToolkit.HoverMenuExtender)
End Class

Produces this error:

error BC32044: Type argument 'SearchResultItem.MyHoverExtenderProperties' does not inherit from or implement the constraint type 'Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)'.

-----------------

MyHoverExtenderProperties.vb

<System.ComponentModel.DefaultProperty("MyProperty")> _
Public Class MyHoverExtenderProperties
Inherits Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuProperties)

Public Property MyProperty() As String
Get
Return GetPropertyStringValue("MyProperty")
End Get
Set(ByVal value As String)
SetPropertyStringValue("MyProperty", value)
End Set
End Property

End Class

This file builds without any errors as far as I can tell.


Oh, sorry, just find my problem.

The MyHoverExtenderProperties class was declared thusly:

Public Class MyHoverExtenderProperties
Inherits Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuProperties)

But it should be declared:

Public Class MyHoverExtenderProperties
Inherits Microsoft.AtlasControlExtender.TargetControlPropertiesBase(Of AtlasControlToolkit.HoverMenuExtender)


That's closer. Does that work?

I think you actually want:

public class MyHoverExtender inherits HoverMenuExtender

public class MyHoverExtenderProperties inherits HoverMenuProperties

What you have above says that you'll be extending controls of type HoverMenuExtender, which I don't think you want.


Yeah, I think you're right. I'm in the process of confusing myself today between wanting to extend my own custom control using a modified version of the hover extender. I think I've almost got my head around it all.

:) Okay if you want more help confusing yourself, just let us know and we'll be glad to lend a hand.

Seriously, our refresh should help with this - I'm concerned you may run into some issues getting the right scripts to load as is. I haven't tried what you're doing so do let us know.

Saturday, March 24, 2012

How can we update a table row using updatepanel?

How can we update a table row using updatepanel? In my example, The whole table is being updated.

<

asp:UpdatePanelID="upLevel1"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<tableborder="1px"><tr><tdstyle="font-size: medium"><asp:LinkButtonID="LinkButton5"runat="server">LinkButton</asp:LinkButton>

<%

=DateTime.Now %></td><td>

<%

=DateTime.Now %></td></tr><asp:UpdatePanelID="upLevel2"runat="server"UpdateMode="Conditional">
<ContentTemplate>
<tr><tdstyle="font-size: medium"><asp:LinkButtonID="LinkButton7"runat="server">LinkButton</asp:LinkButton>

<%

=DateTime.Now %></td><td>

<%

=DateTime.Now %></td></tr></ContentTemplate></asp:UpdatePanel><tr><tdstyle="font-size: medium"><asp:LinkButtonID="LinkButton6"runat="server">LinkButton</asp:LinkButton>

<%

=DateTime.Now %></td><td>

<%

=DateTime.Now %></td></tr></table>
</ContentTemplate></asp:UpdatePanel>

the whole table gets updated because your table is inside the updatepanel. which table row do you want to update? and i assume clicking those Linkbutton will update your row?


Hello,

it seems that you have updatepanels as a direct child of a <table>. This will result illegal markup (rendermode of updatepanel doesn't matter)...

You need something similar which yields to valid markup and I think should works:

<tr><td>Updatepanel here</td></tr>
<tr><td>Updatepanel here</td></tr>
<tr><td>Updatepanel here</td></tr>



In the real app that we are working, the table contains a lot of controls(labels, Input Controls, Grids) and a business rule needs to update a row. I'm trying to optimize the performance especially minimizing the response size to increase the speed of the transmission from server to client.

In my example below, the upLevel2 does not work. I guess update panel does not work in this way. I hope you guys can give me a fix/suggestion on how to best implement this.

Thanks

<asp:LinkButton ID="LinkButton8" runat="server" OnClick="LinkButton8_Click">Toggle 2nd Row Visibility</asp:LinkButton>
<asp:UpdatePanel ID="upLevel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>

<table border="1px">
<tr>
<td style="font-size: medium">
<asp:LinkButton ID="LinkButton5" runat="server">Update Table </asp:LinkButton>
<%=DateTime.Now %>
</td>
<td>
<%=DateTime.Now %>
</td>
</tr>
<asp:UpdatePanel ID="upLevel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>

<tr runat="server" id="tr2">
<td style="font-size: medium">
<asp:LinkButton ID="LinkButton7" runat="server">Update this Row</asp:LinkButton>
<%=DateTime.Now %>
</td>
<td>
<%=DateTime.Now %>
</td>
</tr>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButton8" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<tr>
<td style="font-size: medium">
<asp:LinkButton ID="LinkButton6" runat="server">Update Table </asp:LinkButton>
<%=DateTime.Now %>
</td>
<td>
<%=DateTime.Now %>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

protected void LinkButton8_Click(object sender, EventArgs e)
{
tr2.Visible = !tr2.Visible;
}


for your LinkButton8 to work, you need to add a Trigger to your UpdatePanel:

<asp:UpdatePanelID="upLevel1"runat="server"UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTriggerControlID="LinkButton8"EventName="Click"/>
</Triggers>
...

Every row that you want to update independently, you need to put it in its own Updatepanel. The link button needs to be outside and set the trigger to it. LinkButton8 is a good example that you can follow.

The updatepanel renders as a div or a span element. Because the div and span is an illegal child of the table element, I think your sample won't work. Put the updatepanels inside the td elements. If you want to use updatepanel for hide/show, remove,add or update acomplete tr , I suppose that is not possible (I'm not sure about this, but seems logical). However you can achieve this using javascript or you can change the page layout (do not use table, use divs instead of).

( Currently your example renders the following illegal html:

<table>

<tr> ... </tr>

<div> <-- not valid html, rendered by the upLevel2 updatepanel

<tr> ... </tr>

</div>

<tr> ... </tr>

</table> )

How can we access a control outside the update panel with an control inside the update pan

Take a very simple example, i have a button inside the update panel along with other controls and i have a textbox on the page.What i want is that when i click the button inside the update panel,it should update the textbox which is present outside the update panel.How can i do this?

To my knowledge you cannot update any control outside of the update panel. If you want to update the control move it inside the update panel.

Do you want to modify the text box with server-side code? If so, put it in its own UpdatePanel. Set the UpdateMode on the panel to Conditional. Then you can either add the button in the other UpdatePanel as an AsyncPostBackTrigger to the new UpdatePanel or invoke the Update method on the new UpdatePanel in your button's Click event handler.

If you want to modify the text box on the client, you're going to have to write JavaScript.


Can you please tell me what javascript should i write for the sition i mentioned in the above example.

I am not getting the idea using javascript for a control inside the update panel.


Are you sure you need to write JavaScript? I gave you the steps to modify the text box using purely server-side code by using a second UpdatePanel control. I highly recommend you read theUpdatePanel tutorials and then re-read what I suggested. This path doesn't require JavaScript, but does require a round-trip to the server which is where your code will be executing.

If you do need to use JavaScript, you're going to need to handle the button's click event, modify the other control, and then prevent the default action for clicking the button from occurring (if necessary). This would all be done on the client so wouldn't require a round-trip to the server, but involves learning JavaScript and the DOM API (which you should want to learn as a web developer, anyways).


i have read it but still i feel i need javascript.Can u help me?

Wednesday, March 21, 2012

How can I stop the modal popup from disappearing when a postback occurs?

Hello,

I have a problem.
How can I stop the modal popup from disappearing when a postback occurs.

For example, if I have a button on the modal "form", a click makes it dissappear.

Help!

Thanks!

UPDATE:
I just tried wrapping the postback controls in an updatepanel.

Seems to work so far...this the recommended way?

how can i save panal places after drag and drop

i can use atlas's drag and drop options but i wanna save my panel's positions after drag and drop.

for example i have a 2 area . Left area and right area. and i have 3 draggableListItem.

after i changer draggableListItems's place i wanna write that changesin to xml file or somewhere whish is i can use later.?

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

How can I make a masked label in web forms?

I'm developing a web site using AJAX and I need to display some data in a label but the data must be displayed with a mask.

For example, if I have two textboxes and I wanna do a sum between then, the label must display the result. But, I don't know what can I do to use a masked label.

If somebody can help me I'll be very thankful.

Thanks in advanced

i dont know if i completely understand you. you say you need a lable to display a sum but you want it masked? what exactly do you mean by masked.

a masked label is a lable that replaces certain (or all) characters with something else. For example a credit card number in a masked label could look like

***** ***** **** 3182

you can use a simple string.Replace method, or regular expressions to mask the label. Textboxes even have a Password Type which will mask everything typed into them automatically

What exactly do you want to mask in your label?