Showing posts with label extender. Show all posts
Showing posts with label extender. Show all posts

Wednesday, March 28, 2012

Control Extenders inside View Templates?!?

In the previous versions of the toolkit I could place a control extender inside a view template and everything worked just fine but with today's release (10-20-2006) this appears to have broken.

I have verified this to be true with the TextBox Watermark Extender, the Drop Shadow Extender, and the Rounded Corners Extender.

As an example:

<asp:ScriptManager ID="scriptManager" runat="server" />
<asp:LoginView ID="loginView" runat="server">
<AnonymousTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbw" runat="server" TargetControlID="TextBox1" WatermarkText="WaterMark" />
</AnonymousTemplate>
</asp:LoginView>

This code worked fine in the last version but in this version I do not see the watermark.

Is anyone else experiencing this? If there another way to do this?

Thanks

Sean

The fix is to add the following to your page:

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
loginView.DataBind();
}

The reason is outlined here:http://forums.asp.net/thread/1441672.aspx.

Control Extender, but not a Behavior

Hey All,

I was wondering if it is possible to create a Control Extender that does not render a behavior, but renders binding information instead. From what I've seen, this doesn't seem to be possible and the way I should do this is to implement IScriptControl and then code my own extender per say.

Anybody else doing something like this?

Thx

IScriptControl will get you there - you'll just have to render out all the script manually...


Ok ... that's the path I was heading down.

If I have a control that's markup is like the following

...

<asp:Button id="button1" runat="server" text="Text" /
<Ext:BindingModifier id="BM1" runat="server">
<Ext:BindingModifierProperties TargetControlID="button1" />
</Ext:BindingModifier
can it still be considered an extender or are we just talking about something else at this point?

Generalizing my question, what's the definition of an Extender? Must it emit a behavior?

Thx for the help and being so active on the boards.

Well that's an extender for sure. What XML are you looking to emit exactly?


I'm looking to emit binding information that ties a series of controls to _PageRequestManager's "inPostBack" property.

The point is to disable a series of controls during a postback.

An example of the code I'm looking to emit can be foundat this post.

Thx
Yeah we don't help you too much there. Your other option it so instanitate a behavior that does this instead, either directly (e.g. finds the disabled property and toggles it) or by adding the bindings via the Atlas object model directly.
Ok ... we're going to mimic the way to write the markup of an extender because it makes sense, but implement IScriptControl to handle all of the script output.

Any thoughts on future plans on creating a pre-built library / project template to do something with other sections of xml-script other than behaviors?

control extender for drag and drop - help

I am trying to get drag and drop to work with data dynamically populated from a database. The basic structure layout of the page is based on the work done by Garbin at:

http://aspadvice.com/blogs/garbin/archive/2006/01/17/14730.aspx

I have a master page and some user controls to populate different areas of the page. One of the user controls gets the data from the database and then creates the HTML of the form:

<div id="content1" class="item"> <div id="content1Handle" class="itemHandle">Content 1</div> <div class="itemContent"> <asp:Login ID="myLogin" runat="server" CssClass="centered"></asp:Login> </div> </div> <div id="content2" class="item"> <div id="content2Handle" class="itemHandle">Content 2</div> <div class="itemContent"> <asp:TextBox ID="myTextBox" runat="server"></asp:TextBox> <asp:Button ID="myButton" runat="server" Text="ClickMe" /> </div> </div>

This works OK, but to create the drag and drop behavior, I need to add the following after the end of the </form> tag …

</form> <script type="text/xml-script"> <page> <components><!-- Left Area --> <control id="leftArea"> <behaviors> <dragDropList dataType="HTML" acceptedDataTypes="'HTML'" dragMode="Move" direction="Vertical"> <dropCueTemplate> <template layoutElement="dropCueTemplate" /> </dropCueTemplate> <emptyTemplate> <template layoutElement="emptyTemplate" /> </emptyTemplate> </dragDropList> </behaviors> </control><!-- Right Area --> <control id="rightArea"> <behaviors>

BUT, I do not know how … it has been suggested that I use a control extender, but having viewed the ATLAS vids on the MS website, I cannot understand how a control extender will be able to dynamically create this code after the </form> tag ?

Any ideas anyone ?

Thanks

anyone ? please ... Crying

Consuming a webservice from a custom control extender

I am making a first attempt at writing own extender using the toolkit, and I need to consume a web service. When I Google on Ajax and webservice, I get a lot of articles, but they all seem to involve modifying the ScriptManager tag to point to the web service I want, and you can't rely on that from an extender paradigm. I know the autocomplete control uses some sort of web service, but picking the code out is tough. Is there a plain vanilla, Hello World type of example of how to consume a web service from a custom control extender?

There seems to be a couple of ways to do this, check this post:

http://forums.asp.net/t/1163304.aspx

Although I like mine betterSmile

Hope this helps,

Elias.


Thanks Elias, that's what I was looking for.

Monday, March 26, 2012

Conflict when using Textbox Watermark Extender?

Good day,

I'm trying to find what could be the problem. I'm playing with Textbox watermark extender and it works great, but when I tried using other extenders to same targetcontrol that the watermark is pointing to, I'm getting this kind of error.

Assertion Failed: Duplicate use of ID on

Is it a conflict or but in watermark extender? I'm using the examples of atlas control toolkit as reference. I used the popup control extender and tried to add a watermark extender to one of the text boxes. Then the error appears.

Note: The reason I encountered a problem is because I'm trying to make a textbox with the AutoComplete extender. I thought that adding a watermark extender would make the textbox much more user friendly.

Thanks for any comments.Depending on how the extenders implement their functionality, they may conflict when pointed at the same control. If you post a simple sample, we should be able to identify the conflict if there is one.

Here is the sample code. It is basically a text box with a popup control extender. In the popup control extender you could type some text in the smaller text box and when you had click the Add button it would transfer the text to the larger text box on the top. I added the watermark textbox extender and it begins to show the error. The popup works when the watermark is not used and vice versa. I removed the styles.

Thanks for any help. :)

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering=true runat="server"></atlas:ScriptManager><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtEmailTo" Width=500px runat="server"></asp:TextBox> <div style="width:100%;height:3px;"></div> <asp:Panel BorderColor=black BorderStyle=solid BorderWidth=1px ID="pnlEmailTo" runat="server" Width="504px"> <atlas:UpdatePanel ID="UpdatePanel12" runat="server"> <ContentTemplate> <atlasToolkit:PopupControlExtender ID="PopupControlEmailTo" runat="server"> <atlasToolkit:PopupControlProperties OffsetX=0 OffsetY=2 TargetControlID="txtEmailTo" PopupControlID="pnlEmailto" Position="Bottom" /> </atlasToolkit:PopupControlExtender> <asp:TextBox ID="txtSampleTo" runat="server" Width="300px"></asp:TextBox> <center>  <div style="width:100%;height:3px;"></div> <asp:Button ID="btnAddTo" UseSubmitBehavior=false runat="server" Width=120px Text="Add Text" OnClick="btnAddTo_Click" /> </center> </ContentTemplate> </atlas:UpdatePanel> </asp:Panel> <atlasToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"> <atlasToolkit:TextBoxWatermarkProperties TargetControlID="txtEmailTo" WatermarkText="I'm a watermark" /> </atlasToolkit:TextBoxWatermarkExtender> </div> </form></body></html>

CODE

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass Default2 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { }protected void btnAddTo_Click(object sender, EventArgs e) {try {if (this.txtEmailTo.Text.Trim().Length <= 0) {this.PopupControlEmailTo.Commit(this.txtEmailTo,this.txtEmailTo.Text.Trim().ToString() +this.txtSampleTo.Text.ToString()); }else {this.PopupControlEmailTo.Commit(this.txtEmailTo,this.txtEmailTo.Text.Trim().ToString() +";" +this.txtSampleTo.Text.ToString()); } }catch { } }}

I've just opened work item 224 to track this issue. It says:

"PopupControl and TextBoxWatermark both override the ID property so they can return specifically decorated IDs. This is okay, but they override the set method with a NOOP. This is bad because it means the base class's implementation that actually stores the ID for later use doesn't get called and therefore when pointing two extenders at the same control there will be no way to avoid both extenders assigning themselves the same ID ("_TargetControlID"). The set method should really do something like "base.ID = value;".

Once that's in place, it's possible to avoid the same-naming problem by assigning an ID to either or both of the relevant extender's property lists so that their generated IDs will be non-conflicting ("AssignedID_TargetControlID")."

Making that change and adding an ID to one of your two extenders pointing at the same control seems to fix the problem for me. The resulting behavior's still a little weird since they both key off of focus, etc., but at least it works and will allow non-conflicting extenders to point to the same control.

Thanks for bringing this up!


Ah I see...

Much thanks for the reply, I'd try it later today to see if it is really that weird. :)

Regards,

confirmbuttonextender-advanced

I am using a confirm button extender to fire before the user updates a database. What I would like to do is gather all of the "changes" that will be made and display them in the alert...

Example:

--button 1 sub--

confirmbuttonextender1.confirmtext = textbox1.text & textbox2.text & dropdown1.selectedvalue etc.


Here is the problem... the string is not persisted until a postback takes place... so before someone says use a partial page update or anything that triggers an update... don't... ;)

so basically I need a way to gather the information from the objects BEFORE a postback takes place so that when the user clicks the button the alert will tell the user what changes are about to be made.

Thanks for the help!

You're right, it won't work with server-side script. It would be very simple to write your own javascript confirm and forget about the extender.

------------------
When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


yeah... not quite so simple....

anymore help would be great

ConfirmButtonExtender with Validators ?

Hi -

does anyone know how to make the confirmbutton extender conditionnal on the validation of the page?

For instance, i've got a button with confirm extender that posts information entered in TextBoxes. Some of those textboxes have validators - so the post won't happen if the textboxes aren't correctly filled in (so i don't need an active confirmation in that case). If the boxes are correctly filled in, then i would like the confirmButtonExtender to be active...

Anyway to make that happen?

thanks for the help!

-bash

I believe this would take some additional code in ConfirmButtonBehavior.js. If you happen to implement the feature, we'd love to include it in the Toolkit!

//
// Custom methods
//ADD this bold text to this function and recompile control toolkit tool - this will first validate the page then display the confirmation dialog

_onClick : function(e) {
if (this.get_element() && !this.get_element().disabled) {
// Display confirm dialog and return result to allow cancellation

if(Page_ClientValidate()) {

if (!window.confirm(this._ConfirmTextValue)) {
e.preventDefault();
return false;
}
}
}
},


this is *.js - i have forgot to put rest code - here it is

PART ONE

_onClick :

function(e) {if (this.get_element() && !this.get_element().disabled) {// Display confirm dialog and return result to allow cancellation

if(this._checkValidatorsValue)

{

if(Page_ClientValidate()) {

if (!window.confirm(this._ConfirmTextValue)) {

e.preventDefault();

returnfalse;

}

}

}

else

{

if (!window.confirm(this._ConfirmTextValue)) {

e.preventDefault();

returnfalse;

}

}

}

},

//// Property get/set methods//

get_ConfirmText :

function() {returnthis._ConfirmTextValue;

},

set_ConfirmText :

function(value) {if (this._ConfirmTextValue != value) {this._ConfirmTextValue = value;this.raisePropertyChanged('ConfirmText');

}

},

get_checkValidators :

function() {returnthis._checkValidatorsValue;

},

set_checkValidators :

function(value) {if (this._checkValidatorsValue != value) {this._checkValidatorsValue = value;this.raisePropertyChanged('checkValidators');

}

}

PART TWO - add this to this file *.cs

[

ExtenderControlProperty()]publicbool checkValidators

{

get

{

return GetPropertyBoolValue("checkValidators");

}

set

{

SetPropertyBoolValue(

"checkValidators",value);

}

}

PART THREE

NOW IF YOU WANT TO USE CONFIRM DIALOG WITH VALIDATORS YOU SHOUL SET IN ASPX FILE IN CONFIRMBUTTONEXTANDER PROPERTY CHECKVALIDATORS TO TRUE

IF YOU WANT TO USE CONFIRM DIALOG WITHOUT VALIDATORS (FOR EXAMPLE ON PAGE THERE ARE NOT VALIDATORS) SET THIS PROPERTY TO FALSE


Related to my reply inthis thread, I believe. The code here seems to be a move along the path to add the mentioned submit event support to ConfirmButton.


FYI, I've just fixed this issue:http://www.codeplex.com/WorkItem/View.aspx?ProjectName=AtlasControlToolkit&WorkItemId=8342.

Confirmbutton Question

I put a ConfirmButton extender for a button. This button is a submit button which is put in the last step of Wizard. The wizard has validations.

My problem is the ConfirmButton dialog doesn't pop up before the validation logic kicks in.

Any clue?

Try to set UseSubmitBehaviour property of button

For additional information

Validation controls, which includes theBaseCompareValidator,BaseValidator,CompareValidator,CustomValidator,RangeValidator,RegularExpressionValidator,RequiredFieldValidator, andValidationSummary control are not compatible with UpdatePanel

http://weblogs.asp.net/scottgu/archive/2007/01/25/links-to-asp-net-ajax-1-0-resources-and-answers-to-some-common-questions.aspx

Download compatible version of validators from here

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

ConfirmButton Problem

Hi all, im new here and also to asp/ajax.. ive got a slight question to ask which may be simple.. im using the confirmbutton extender programatically as shown below

Dim lnkOptionAs New LinkButton lnkOption.Width = 50 lnkOption.Text ="Delete" lnkOption.ID = lblUser.TextAddHandler lnkOption.Click,AddressOf Delete ContentPanel2.Controls.Add(lnkOption)Dim btnConfirmAs New AjaxControlToolkit.ConfirmButtonExtender btnConfirm.TargetControlID = lblUser.Text btnConfirm.ConfirmText ="Are you sure you want to delete ?"

It retrieves a list of users and lists them down on a page using a for loop... now id like each option to have a delete ability as shown in the code above.. however the code doesnt seem to work as i think im missing something out since it doesnt show the text "Are you sure you want to delete ?"

Thanks :)

I don't see any code that adds the btnConfirm to the page...are you doing this?

Jason

Saturday, March 24, 2012

Confirm Extender + Modal Popup -> Call JavaScript on the load, and exit.

I have a Confirm Extender workign with a modal popup extender.

What I'd "like" to do is when the button that launches both is clicked, to run some client script to populate some fields. This saves me from doing it on the server. however, even using OnCLientClick on the button initiating all of this it doesn't work.

Any thoughts?

Also, when I click the OK button close the modal popup confirm box.. .(say that 10x as fast as you can), it would be better for it to close right away, rather than close when the server is done processing.

Is it possible to run script before it hits the server to make the display:none; again?

Hi RTernier,

RTernier:

What I'd "like" to do is when the button that launches both is clicked, to run some client script to populate some fields. This saves me from doing it on the server. however, even using OnCLientClick on the button initiating all of this it doesn't work.

Here is a workable example which you can compare with yours.

<%@. Page Language="C#" %><%@. Import Namespace="System.Threading" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { Thread.Sleep(3000); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style> .modalBackground { background-color:Gray; filter:alpha(opacity=70); opacity:0.7; } .modalPopup { background-color:#FFD9D5; border-width:3px; border-style:solid; border-color:Gray; padding:3px; width:250px; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager><%=DateTime.Now.ToString()%> <asp:Button ID="Button1" runat="server" Text="Button" /><ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1" DisplayModalPopupID="ModalPopupExtender1" > </ajaxToolkit:ConfirmButtonExtender> <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none"> Are you sure? <asp:Button ID="btnOk" runat="server" Text="Ok" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" /> </asp:Panel> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1" PopupControlID="Panel1" CancelControlID="btnCancel" BackgroundCssClass="modalBackground" OkControlID="btnOk"> </ajaxToolkit:ModalPopupExtender> <script type="text/javascript" language="javascript"> function pageLoad(){ $find("<%=ModalPopupExtender1.ClientID%>").add_showing(onMPEShowing); } function onMPEShowing(){ //your javascript code here to add fields or do anything what you want. } </script> </form></body></html>

RTernier:

Also, when I click the OK button close the modal popup confirm box.. .(say that 10x as fast as you can), it would be better for it to close right away, rather than close when the server is done processing.

Is it possible to run script before it hits the server to make the display:none; again?

It will be hidden right after be clicked. Please see my sample

Hope this helps.

Best regards,

Jonathan


I can not say how grateful I am for this solution. Wanted same functionality in my app.

I have 1 question though. Is there any client script reference for methods like add_showing etc. I also wanted to do some client side scripting on modal popup closing ..and i just guessed the function (must be my luck day) add_hiding..which worked beautifully!

However, I would still love a client side script reference for the same. Please advise. Thanks!

Confirm deleting using ModalPopup in GridView

Hi there!

I want to confirm deleting row from GridView using a ModalPopup Extender. Please tell me, how can I do it?

I.e., how to show ModalPopup Panel when user click a Delete button, and how to cansel deleting when user click a Cansel button on ModalPopup Panel and confirm deleting when click a OK Button.

Please, someone, help meCrying


check this article to show modalpopup and do postback when you click the 'OK' button on the ModalPopup.

http://www.aspdotnetcodes.com/ModalPopup_Postback.aspx

confirm button extender in a datagrid

Hi all,

Quick Question.

How can you use a confirm button extender in a datagrid?

So if you have a datagrid with 10 rows, each with a delete link button at the end and you want the confirm dialouge to popup everytime you click on any of the 10 delete link buttons. How do you do it?

Thanks in advance.

Use the rowdatabound event to add an attribue to thelinkbutton("DELETE"), assuming the linkbutton is in the first column ofthe gridview:


If e.Row.RowType = DataControlRowType.DataRowThen
Dim lbAs LinkButton
lb = e.Row.Cells(0).Controls(0)
lb.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete this row?');")
End If
OnClientClick="return confirm('Are you sure you want to delete
this item?');"

However,to make that work, you'll need to convert the Delete button into aTemplate field. The following post gives more details about this:

http://p2p.wrox.com/topic.asp?TOPIC_ID=45586

cheers


Thanks,

I allready have that. I allready have a javascript confirm dialouge.

I wanted to use the confirm button exetender in the ajax tool kit. I know its exactly the same, but i thought i would try the "new thing".

Thanks for your response though.


Just add a confirmbuttonextender in the template for the column so that one gets created for every row of the grid.

i did this...

<

asp:GridViewID="grvReservas"runat="server"CellPadding="4"GridLines="None"Height="81px"Style="z-index: 115; left: 58px; position: absolute; top: 328px"Width="691px"OnRowDeleting="grvReservas_RowDeleting"OnSelectedIndexChanged="grvReservas_SelectedIndexChanged"ForeColor="#333333"><FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"/><RowStyleBackColor="#EFF3FB"/><SelectedRowStyleBackColor="#D1DDF1"Font-Bold="True"ForeColor="#333333"/><PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"/><HeaderStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/><AlternatingRowStyleBackColor="White"/><Columns><asp:CommandFieldShowDeleteButton="True"/><asp:TemplateField><ItemTemplate><asp:ImageButtonID="ImageButtonDelete"runat="server"CausesValidation="false"CommandName="ImageButtonDelete"ImageUrl="../images/eliminar.jpg"OnClick="ImageButtonDelete_Click"Visible="true"/><cc1:ConfirmButtonExtenderID="ConfirmButtonExtender1"runat="server"ConfirmText="?Esta seguro que desea cancelar la reserva seleccionada?"TargetControlID="ImageButtonDelete"></cc1:ConfirmButtonExtender></ItemTemplate></asp:TemplateField><asp:ImageField></asp:ImageField></Columns><EditRowStyleBackColor="#2461BF"/>

</asp:GridView>

but in ImageButtonDelete_Click method, how do i know which row is selected?????


You could add a commandargument to the imagebutton with some kind of ID value that identifies the data that you want to delete.
how can i add a commandargument to the imagebutton with the ID value ?

Hookup to the rowdatabound event of the gridview and then set the property in there.

Confirm button extender and validation controls

Hi,

I am using the confirm button extender in conjunction with some required field validators. Is there any way to stop the extender popping up if the page isn't valid? They are clearly both fired at the same time client-side from the button click event.

Andy

Im wondering this too...did you find a solution?

I only want a confirmation dialog if it passes all validation first.

Confirm button extender

Now this is a very useful extender but I wonder if anyone has tried to enhance its looks ?

I was looking for a confirm button like the ballons i can see on

http://www.mainetoday.com/wendy/toolbar/demo.html

when i hover over the menu items at the top

To have a custom Confirm Button you could use ModalPopup instead. If you would like it to show the same way it is showing on that linked page you could use the HoverMenu and style it as you would like. We had a balloon popup extender in the making but it is not close to being done any time soon.

Conditional PopupControlExtender

I've seen all kinds of examples using the popup control extender being tied to textbox, I was wondering if there was a way to tie it to a checkbox or checkboxlist and have it only appear when an item is checked. I havent got any issues getting it to show up, but is it possible and if so how do you make it only appear when the control is being checked.

Thanks for any advice/guidance that you can provide.

You could attach a popup control extender to an invisible control and call its show method in the onclick event handler of the checkbox depending on what value is set.

Here is a post that talks about this problem:

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

Conditional Logic in the Web Service that feeds the AutoComplete extender ? ?

I have a Autocomplete extender that is "tied" to a web service ... the web service basically populates an array of folder names in a directory (these folder names also happen to be server names)

It works great, I get a full list of folder names (servers) with the following code (this is a chunk of the relevant code) ... However I need any of the "If" statements to work, but when I use these, I get nothing when I press keys ... i.e. known folder names

GetServerNames.vb

==============

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.IO.Directory

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class GetServerNames
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function ReturnServerFolders(ByVal prefixText As String, ByVal count As Integer) As String()
Dim strFolderPath As String = ("C:\SERVER_FILES\")
Dim arrDirectories As String() = System.IO.Directory.GetDirectories(strFolderPath)
Dim strDirectory As String
Dim items As New List(Of String)
For Each strDirectory In arrDirectories
strDirectory = Replace(strDirectory, strFolderPath, "")
'If prefixText = Left(strDirectory, prefixText.Length) Then '<- does not work returns no names
'If strDirectory.StartsWith(prefixText) Then '<- does not work returns no names
'If InStr(strDirectory, prefixText) Then '<- does not work returns no names
items.Add(strDirectory) '<- works always with no if logic returns all folder names
'End If
Next
Return items.ToArray()
End Function

End Class

Default.aspx

=========

<asp:TextBoxID="TextBox1"runat="server"Width="130px"></asp:TextBox>

<cc1:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="TextBox1"

ServicePath="GetServerNames.asmx"ServiceMethod="ReturnServerFolders"

MinimumPrefixLength="2"CompletionSetCount="20"CompletionInterval="1000"

EnableCaching="true"Enabled="true">

</cc1:AutoCompleteExtender>

Maybe it's just a case (!) of case sensitivity.

If strDirectory.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase)


Yep, Thanks

That is it ...

Actually the lightbulb went off when I saw this post

http://support.jodohost.com/archive/index.php?t-9497.html

I was coming back here to post a "solved" ... I knew when I saw a reply that would be it ;-)

I am going to go with the InStr function because this field is actually a "Server Name" field ... this could be helpful if looking for a server name with "WEB" in it regardless of what it begins with.

Here is the working ServiceMethod for this

===============================

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.IO.Directory

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class GetServerNames
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function ReturnServerFolders(ByVal prefixText As String, ByVal count As Integer) As String()
Dim strFolderPath As String = ("C:\SERVER_FILES\")
Dim arrDirectories As String() = System.IO.Directory.GetDirectories(strFolderPath)
Dim strDirectory As String
Dim items As New List(Of String)
For Each strDirectory In arrDirectories
strDirectory = Replace(strDirectory, strFolderPath, "")
If InStr(Ucase(strDirectory), Ucase(prefixText)) Then
items.Add(strDirectory)
End If
Next
Return items.ToArray()
End Function

End Class

Wednesday, March 21, 2012

Composite control and MaskedEdit

I have a composite control that includes a textbox. I want to use the masked edit extender on this control, but I get the 'Unable to cast object to textbox" error. Is there a work around for this?

Thanks,
Rhonda

Hi Rhoda,

The maskedEdit control is extender to object TextBox :

...
[TargetControlType(typeof(TextBox))]
public class MaskedEditExtender : ExtenderControlBase
...

The MaskedEdit Control would not have as to control composite. For example , The composite has 2 textbox. Which will be associated? On the events, that events will be controlled (ex: keypress), of the composite or internal the textbox ?


Hi Rhodas,

Perhaps workaround is to create one webcontrol with Textbox + MaskedEdit.


I like the idea of adding the masked edit to my composite control, but I'm not sure how to do that. There's no HTML involved and I can't access the extender in code. Any ideas?

Thanks,
Rhonda


Hi Rhonda,

Sorry, I worte wrong :

.. create onewebUsercontrol with Textbox + MaskedEdit.


Glad I found that thread; that's exactly what I'm trying to do (a composite control with a textbox and a FilteredTextBoxExtender)!

I haven't had any luck 'till now (those are my first custom controls, and tutorials for that subject are rare, to say the least...)

Now, am I understanding correctly that you are saying that ExtenderControls can't be encapsulated in CustomServerControl? (I'm deriving from CompositeControl, for my part.)

regards.