Showing posts with label textbox. Show all posts
Showing posts with label textbox. Show all posts

Wednesday, March 28, 2012

Disable Autocomplete extender in code

Is there any way to disable an autocompleteextender?

I have an autocompleteextender that works fine with a textbox but I need to hide that textbox. When I hide it, a javascript exception is thrown because the atlas code can't find the control. What should I do to disable the autocompleteextender in code?

Thanks

I was using this code:

foreach

(AutoCompleteProperties propin AutoCompleteExtender1.TargetProperties) {

prop.Enabled =

false;

}

But it didn't work. However with this it works:

AutoCompleteExtender1.TargetProperties.Clear();

Probably there's a bug somewhere because I think what I was doing should be enough.


hello.

how are you hiding the textbox? i'm guessing that you're setting the visible property to false...unfortunatelly, it looks like the xml script willnot be rendered itht ie enabled property is set to false. you can try to set both the visible and enabled properties of the associated textbox controls to false and this should stop the generation of the xml-script...


It is inside a table row so I set the table row to runat=server and set visible = false to the table row.

I have just tried setting the textbox enable and visible properties to false but it still doesn't work. I think that the correct behaviour should be not to render the xml-script related to the autocomplete textbox when the associated TargetProperty is not enabled.


hello again.

hum...after looking at what's going on, i think that the problem is that the behavior is being registered even when the control is not visible. you can change this by building your own completeextender with code similar to this one:

namespace

LA

{

publicclassBetterAutoCompleteExtender :AutoCompleteExtender

{

protectedoverridevoid OnPreRender(EventArgs e)

{

WebControl ctl =this.NamingContainer.FindControl(this.TargetProperties[0].TargetControlID)asWebControl;if ( ctl !=null && ctl.Visible &&this.TargetProperties[0].Enabled )

{

base.OnPreRender(e);

}

}

}

}

hope this helps (btw, you should open a bug report by adding a new post to the forum and redirect them to this post to get more info about the problem - don't forget to add the [BUG] word on the title).


Thanks Luis.

With that it works properly.

I'll add a new post with the bug.


Hello,

I'm attempting to put the autocomplete extender in a tabbed form. Is there a way to disable the autocomplete when the style of the div layer that the textbox is in gets set to style="display:none"?

Thanks,
Emilie

hello.

hum...in your scenario, you shouldn't need to disable it because if you're setting the display style, that means that all the elements will be loaded and you won't get errors when searching for them...


Here's the simple sample I'm working with:

<body>
<form id="Form1" runat="server">
<atlas:ScriptManager id="AtlasPage1" runat="server" />

<div style="display:none">
<asp:TextBox ID="TextBox1" runat="server"/>
</div>

<Atlas:AutoCompleteExtender runat="server" ID="autoComplete2">
<Atlas:AutoCompleteProperties TargetControlID="TextBox1"
Enabled="True" ServicePath="AutoCompleteService.asmx"
ServiceMethod="GetWordList"
minimumprefixlength="1" />
</Atlas:AutoCompleteExtender>
</form>
</body
Right now it gives me an "invalid argument" exception and cannot find the source code to break to.
However, if I remove style="display:none" from the div, it works fine.
I ran it again this morning and this time it was able to break to the line of code that was failing. In the Webresource.axd file there's a line

completionListStyle.width = (elementBounds.width - 2) + 'px';

But when the div is set to display:none, elementBound.width (referring to the width of the textbox) is 0.

Anyone have ideas on how to get around this?
I'm having the same problem here: when display: none is set, the autocompleteextender throws up an error.

Is there a workaround for this yet?

any news on this one, I have the same problem?

Andy

Disable Atlas things at runtime

I've got a form i am trying to create that if:

An administrator is logged in, a textbox with an AutoCompleteExtender (and TextWaterMark control as well) is available for the Admin to search for companies to look at data for

If it's a company logged in, i want to hide/disable this textbox and instead give them a dropdownlist of their assigned company (or companies) and not allow them to search for companies outside of them

the problem i am running into is that when i set the textbox to "visble = false", that causes Atlas to throw an error "Assertion Failed, could not find HTML element blah blah blah"...

I thought i'd be sneaky and instead of saying:
txtCompany.Visible = False

I instead said in the code
txtCompany.Style.Add("display", "none")

but that still errored, althought this time just a "runtime error has occured"

How can i simply say in code:

"If i am not an administrator, turn off the textbox, autocomplete, and watermark"

I'd probably put the entire textbox (atlas update panel included) inside a usercontrol, and show and hide the usercontrol accordinly.
Excellent suggestion and appears to be doing exactly what i want it to do......

Difficulties using an asp:ImageButton and the PopupControlExtender

I have a textbox and an asp:ImageButton. I would like the Image button to be able to launch the calendar control using the PopupControlExtender and then insert the date into the textbox from selecting it on the calendar. Not sure that I am even close in my example. I am unsure as to what should be in the code behind(C#) as well. Any help would be appreciated.

<

atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server"></atlas:ScriptManager><asp:TextBoxID="DateTextBox"runat="server"></asp:TextBox><asp:ImageButtonID="ImageButton1"runat="server"ImageUrl="~/Images/Calendar.gif"/><asp:PanelID="Panel1"runat="server"CssClass="popupControl"><atlas:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><atlasToolkit:PopupControlExtenderID="PopupControlExtender1"runat="server"><atlasToolkit:PopupControlPropertiesTargetControlID="ImageButton1"PopupControlID="Panel1"Position="Bottom"/></atlasToolkit:PopupControlExtender><center><asp:CalendarID="Calendar1"runat="server"BackColor="White"BorderColor="#999999"CellPadding="1"DayNameFormat="Shortest"Font-Names="Verdana"Font-Size="8pt"ForeColor="Black"Width="160px"OnSelectionChanged="Calendar1_SelectionChanged"><SelectedDayStyleBackColor="#666666"Font-Bold="True"ForeColor="White"/><TodayDayStyleBackColor="#CCCCCC"ForeColor="Black"/><SelectorStyleBackColor="#CCCCCC"/><WeekendDayStyleBackColor="#FFFFCC"/><OtherMonthDayStyleForeColor="#808080"/><NextPrevStyleVerticalAlign="Bottom"/><DayHeaderStyleBackColor="#CCCCCC"Font-Bold="True"Font-Size="7pt"/><TitleStyleBackColor="#999999"BorderColor="Black"Font-Bold="True"/></asp:Calendar></center></ContentTemplate></atlas:UpdatePanel></asp:Panel>

PopupControl's natural behavior is to add the commit text to its TargetControlID. You want the text to go to a different control, so that's why it's a little more difficult. However, you should be able to get this to work thanks to PopupControl's extensibility. What should work is:

1. Set the CommitProperty property to something handy like "value". This will tell PopupControl to store the commit text in a "value" property on the TargetControlID (an image in your case).

2. Set the CommitScript property to some JavaScript code that reads the commit text from TargetControlID.value and sets it to the intended text box.

That's the general idea - if it doesn't work for you, please follow up here.


Hi David,

I tried the steps you mentioned. Everytime I click on the Imagebutton the calendar displays(flickers) and then disappears, however, when I right click the button the calendar stays open and i can choose a date and it appears in the textbox. What else am I doing wrong?

<

scriptlanguage="javascript"type="text/javascript">function getCalendarValue()

{

document.getElementById('DateTextBox').value = document.getElementById('ImageButton1').value;

} getCalendarValue()

</script>

</head>

<body>

<formid="form1"runat="server"><atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server"></atlas:ScriptManager><asp:TextBoxID="DateTextBox"runat="server"></asp:TextBox><asp:ImageButtonID="ImageButton1"runat="server"ImageUrl="~/Images/SmallCalendar.gif" />

<asp:PanelID="Panel1"runat="server"CssClass="popupControl"><atlas:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><atlasToolkit:PopupControlExtenderID="PopupControlExtender1"runat="server"><atlasToolkit:PopupControlPropertiesTargetControlID="ImageButton1"PopupControlID="Panel1"Position="Bottom"CommitProperty="value"CommitScript="getCalendarValue()"/></atlasToolkit:PopupControlExtender><center><asp:CalendarID="Calendar1"runat="server"BackColor="White"BorderColor="#999999"CellPadding="1"DayNameFormat="Shortest"Font-Names="Verdana"Font-Size="8pt"ForeColor="Black"Width="160px"OnSelectionChanged="Calendar1_SelectionChanged"><SelectedDayStyleBackColor="#666666"Font-Bold="True"ForeColor="White"/><TodayDayStyleBackColor="#CCCCCC"ForeColor="Black"/><SelectorStyleBackColor="#CCCCCC"/><WeekendDayStyleBackColor="#FFFFCC"/><OtherMonthDayStyleForeColor="#808080"/><NextPrevStyleVerticalAlign="Bottom"/><DayHeaderStyleBackColor="#CCCCCC"Font-Bold="True"Font-Size="7pt"/><TitleStyleBackColor="#999999"BorderColor="Black"Font-Bold="True"/></asp:Calendar></center></ContentTemplate></atlas:UpdatePanel></asp:Panel></form>
You were SO close! You're using an ImageButton which has submit semantics - it's the submit that's causing the flicker and messing stuff up. Change it to an Image instead, and it works great. Here's the code:
<%@. Page Language="C#" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %><!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 Calendar1_SelectionChanged(object sender, EventArgs e) { PopupControlExtender1.Commit(Image1, Calendar1.SelectedDate.ToString()); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function getCalendarValue() { document.getElementById('DateTextBox').value = document.getElementById('Image1').value; }// getCalendarValue() </script></head><body> <form id="form2" runat="server"> <atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server"> </atlas:ScriptManager> <asp:TextBox ID="DateTextBox" runat="server"></asp:TextBox> <asp:Image ID="Image1" runat="server" ImageUrl="~/ToggleButton/ToggleButton_Checked.gif" /> <asp:Panel ID="Panel1" runat="server" CssClass="popupControl"> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server"> <atlasToolkit:PopupControlProperties TargetControlID="Image1" PopupControlID="Panel1" Position="Bottom" CommitProperty="value" CommitScript="getCalendarValue()" /> </atlasToolkit:PopupControlExtender> <center> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Width="160px" OnSelectionChanged="Calendar1_SelectionChanged"> <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" /> <TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" /> <SelectorStyle BackColor="#CCCCCC" /> <WeekendDayStyle BackColor="#FFFFCC" /> <OtherMonthDayStyle ForeColor="#808080" /> <NextPrevStyle VerticalAlign="Bottom" /> <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" /> <TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" /> </asp:Calendar> </center> </ContentTemplate> </atlas:UpdatePanel> </asp:Panel> </form></body></html>

Awesome! I changed it and it worked like a charm. Thanks David! The only other thing I noticed was that when the page loads, it seems like the calendar control shows for a brief second and disappears. How would I get around this?
Look at the .popupControl style used by the samples - it applies "visibility:hidden" to the relevant panel from the very beginning. That way the browser never tries to show it until it's popped.
Thanks for your help!! Genious!!!

Hi;

I followed your code.

Can you let me know why the document.getElementById can't find my contols? I had to look into the source of my page and find out that the name is of my text box isctl00$ContentPlaceHolder1$tbActivationDate instead oftbActivationDate?

the javascript function worked when I did this:

document.getElementById('ctl00$ContentPlaceHolder1$tbActivationDate').value = document.getElementById('ctl00_ContentPlaceHolder1_ImgActivationDate').value


The name of the control may have been ctl00$xxx, but the getElementById works off of the id which would have been ctl00_xxx. If you refer to the control by the '_' version, I this should will work fine.
Thanks, this worked like a charm! One question, though...

I was dynamically creating the javascript, like so:

sb.Append("function GetCalendar1Value(){"); sb.Append("document.getElementById('" + tbBeginDate.UniqueID +"').value = " +"document.getElementById('" + imgCal1.UniqueID +"').value;"); sb.Append("}");
However, this created a full name of "ctl00$ContentPlaceHolder1$imgCal1", which didn't work. I hardcoded it to "ctl00_ContentPlaceHolder1_imgCal1" and it works.

Why doesn't the UniqueID work for the <asp:image> control, or is there a better way of doing it? I guess it works as is, I'm just curious. Thanks!
Hi edmicman,

You may want to check out theClientID property. I think this is more along the lines of what you're looking for...

Thanks,
Ted
Thanks! But doesn't .ClientID only return the ASP.NET ID, i.e. "imgImage1" instead of the full name of the control within a master page, etc. ("ctl00_content... etc.)? It seems like I tried that before and it needed the full name or something. I'll try it again...

Thanks a lot, I was looking for this code and it works fine!


When I try to use this with MasterPages, it doesn't work anymore (yesterday I tried it on a single asp.net page for tests).

I have my JavaScript placed in the <head></head> part of my MasterPage (when I try another JavaScript placed on my MasterPage, it just works fine)

What am I doing wrong?


Hi Hopke,

I'm not sure what's going wrong with this. Perhaps you can post a small sample that still contains the problem so I can try to help.

Thanks,
Ted

Difference betwwen CTP and beta 1 with GetPostBackEventReference

Hello,

Last week I have create a page with a gridview with textbox in the header row create dynamically.

For each textbox, I had this code in the creating code :

PostBackOptions postBackOptions =new PostBackOptions(oTextBox);
postBackOptions.ClientSubmit =true;
oTextBox.Attributes.Add("onkeyup",string.Format("{0}", ClientScript.GetPostBackEventReference(postBackOptions),oTextBox.ID));

With this code, when I make a keyup in a textbox, the gridview is refresh in "Ajax mode" but now, with the Beta 1, the entire page is postaback.

Can you know why ?

PostBackOptions postBackOptions =new PostBackOptions(oGridView);
postBackOptions.ClientSubmit =true;
oTextBox.Attributes.Add("onkeyup",string.Format("{0}", ClientScript.GetPostBackEventReference(postBackOptions),oTextBox.ID));


hello,

can you show us the code that is not working?


Hi,

I had a similar problem, but after stepping through the new JavaScript libraries, I came to the conclusion that it was because the control passed to the PostBackOption constructor is not itself inside the UpdatePanel.

Moving it inside the UpdatePanel solved the problem.

Hope this helps,

Bo

Monday, March 26, 2012

Detailsview in updatepanel with dropdownlist SelectedIndexChanged to update textbox(s) val

I am new to the updatepanel and need some help. I have a gridview control and a detailsview control. The detailsview control is displayed for edits on the gridview row select command. These controls are wrapped in an updatepanel, there are 2 textboxes that I want to update with calculated values based on the selected value of the dropdownlist. I was trying to accomplish this by using the SelectedIndexChanged of the ddlScheduleType dropdownlist in codbehind.

How do I get this to work, am I on the right track? Any help would be greatly appreciated, code is below.

Protected

Sub ddlScheduleType_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)'Get a refernce to the dropdownlist:Dim ddlScheduleTypeAs DropDownList =CType(CType(sender, DetailsView).FindControl("ddlScheduleType"), DropDownList)Dim nDistroyDaysAsInteger = Utility.GetBoxCatDestroyDays(ddlScheduleType.SelectedValue)Dim ctrlTbDYAs TextBox =CType(CType(sender, DetailsView).FindControl("tbDestroyYear"), TextBox)Dim ctrlTbDMAs TextBox =CType(CType(sender, DetailsView).FindControl("tbDestroyMonth"), TextBox)Dim ctrlTbDEAs TextBox =CType(CType(sender, DetailsView).FindControl("tbDateEnd"), TextBox)

<%

@dotnet.itags.org.PageLanguage="VB"MasterPageFile="~/Default.master"AutoEventWireup="false"CodeFile="drEdit.aspx.vb"Inherits="drEdit"title="Untitled Page" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxtoolkit" %>

<%

@dotnet.itags.org.RegisterNamespace="CustomBoundField"TagPrefix="custom" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="MainContent"Runat="Server">

<

ajax:ScriptManagerid="sm1"EnablePartialRendering="True"runat="server"/><table><tr><tdalign="Center"valign="Top"><ajax:UpdatePanelid="up2"runat="server"><contentTemplate><asp:GridViewRunat="server"Id="gvDrMaster"GridLines="Both"cellpadding="1"cellspacing="0"Headerstyle-BackColor="#BDCFE7"Headerstyle-Font-Names="Verdana,Helvetica,Arial;"Headerstyle-Font-Size="8"BackColor="#E7EFFF"Font-Names="Verdana,Helvetica,Arial;"Font-Size="8"BorderColor="Black"DataSourceID="SqlDsMaster"DataKeyNames="dr_id"AllowPaging="True"AllowSorting="True"PageSize="50"AutoGenerateColumns="False"><Columns><asp:CommandFieldShowSelectButton="True"/><asp:BoundFieldDataField="box_barcode"HeaderText="Barcode"/><asp:BoundFieldDataField="box_description"HeaderText="Description"HeaderStyle-HorizontalAlign=LeftItemStyle-HorizontalAlign=left/><asp:BoundFieldDataField="box_location"HeaderText="Location"/><asp:BoundFieldDataField="status_name"HeaderText="Status"/><asp:BoundFieldDataField="site_name"HeaderText="Site"/><asp:BoundFieldDataField="dr_id"ReadOnly="True"HeaderText=""HeaderStyle-Width="0"/><asp:BoundFieldDataField="box_site"ReadOnly=trueHeaderText=""HeaderStyle-Width="0"/></Columns><SelectedRowStyleBackColor=AliceBlue/></asp:GridView><triggers><ajax:controlValueTriggercontrolid="gvDrmaster"propertyname="Select"/></triggers></contentTemplate></ajax:UpdatePanel></td><tdalign="Left"valign="Top"><ajax:UpdatePanelid="up1"UpdateMode=Alwaysrunat="server"><contentTemplate><asp:DetailsViewDataKeyNames="dr_id"DataSourceID="SqlDsDetail"GridLines="Both"cellpadding="1"cellspacing="0"Headerstyle-BackColor="#BDCFE7"Headerstyle-Font-Names="Verdana,Helvetica,Arial;"Headerstyle-Font-Size="8"BackColor="#E7EFFF"Font-Names="Arial"Font-Size="8"BorderColor="Black"HeaderText="Author Details"AutoGenerateRows="False"HeaderStyle-Font-Bold="True"OnItemUpdated="DVAfterUpdate"ID="dvDrMaster"runat="server"><Fields><asp:BoundFieldDataField="dr_id"HeaderText="ID"ReadOnly="True"ControlStyle-CssClass="dvDataField"/><asp:BoundFieldDataField="box_barcode"HeaderText="Barcode"ControlStyle-CssClass="dvDataField"/><custom:BoundTextBoxFieldCssClass="dvDataField"DataField="box_description"HeaderText="Description"TextMode="MultiLine"Rows="5"Columns="50"Wrap="True"/><asp:TemplateFieldHeaderText="Box Category"><ItemTemplate><asp:Labelid="lblScheduleType"runat="server"Text='<%# Container.DataItem("schedule_record_type")%>'/></ItemTemplate><EditItemTemplate><asp:DropDownListrunat="server"id="ddlScheduleType"DataSourceID="dsScheduleType"SkinID=ddlBackColor="Pink"DataTextField="schedule_record_type"DataValueField="schedule_id"AutoPostBack=trueOnSelectedIndexChanged="ddlScheduleType_SelectedIndexChanged"SelectedValue='<%# Bind("box_schedule_type")%>'/></EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Status"><ItemTemplate><asp:Labelid="lblStatus"runat="server"Text='<%# Container.DataItem("status_name")%>'/></ItemTemplate><EditItemTemplate><asp:DropDownListrunat="server"id="ddlStatus"DataSourceID="dsStatus"SkinID=ddlBackColor="Pink"DataTextField="status_name"DataValueField="status_id"SelectedValue='<%# Bind("box_status")%>'/></EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Site"><ItemTemplate><asp:Labelid="lblSiteName"runat="server"Text='<%# Container.DataItem("site_name")%>'/></ItemTemplate><EditItemTemplate><asp:DropDownListrunat="server"id="ddlSite"DataSourceID="dsSite"BackColor="Pink"SkinID=ddlDataTextField="site_name"DataValueField="site_id"SelectedValue='<%# Bind("box_site")%>'/></EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Box Location"><ItemTemplate><asp:Labelid="lblLocation"runat="server"Text='<%# Container.DataItem("box_location")%>'/></ItemTemplate><EditItemTemplate><asp:DropDownListrunat="server"id="ddlBoxLocation"DataSourceID="SQLDSLocation"BackColor="Pink"SkinID=ddlDataTextField="location_id"DataValueField="location_id"SelectedValue='<%# Bind("box_location")%>'/></EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Cardholder Data"><ItemTemplate><asp:Labelid="lblCardholder"runat="server"Text='<%# Container.DataItem("box_cardholder_desc")%>'/></ItemTemplate><EditItemTemplate><asp:DropDownListrunat="server"id="ddlCardholder"BackColor="Pink"SkinID=ddlDataTextField="box_cardholder_desc"DataValueField="box_cardholder"SelectedValue='<%# Bind("box_cardholder")%>'><asp:ListItemSelected="True"Value=""Text=""/><asp:ListItemValue="Y"Text="Yes"/><asp:ListItemValue="N"Text="No"/></asp:DropDownList>

</EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Dept"><ItemTemplate><asp:Labelid="lblDept"runat="server"Text='<%# Container.DataItem("dept_name")%>'/></ItemTemplate><EditItemTemplate><asp:DropDownListrunat="server"id="ddlDept"DataSourceID="SQLdsDepartment"BackColor="Pink"SkinID=ddlDataTextField="dept_name"DataValueField="dept_id"SelectedValue='<%# Bind("fiserv_dept")%>'/></EditItemTemplate></asp:TemplateField>

<asp:BoundFieldDataField="date_start"HeaderText="Start Date"ControlStyle-CssClass="dvDataField"/>

<asp:TemplateFieldHeaderText="End Date"><ItemTemplate><asp:Labelid="lblDateEnd"runat="server"Text='<%# Container.DataItem("date_end")%>'/></ItemTemplate><EditItemTemplate><asp:TextBoxID="tbDateEnd"SkinID=tbrunat="server"Text='<%# Bind("date_end")%>'/></EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Destroy Month"><ItemTemplate><asp:Labelid="lblDestroyMonth"runat="server"Text='<%# Container.DataItem("date_dest_month")%>'/></ItemTemplate><EditItemTemplate><asp:TextBoxID="tbDestroyMonth"SkinID=tbrunat="server"ReadOnly=trueText='<%# Bind("date_dest_month")%>'/></EditItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Destroy Year"><ItemTemplate><asp:Labelid="lblDestroyYear"runat="server"Text='<%# Container.DataItem("date_dest_year")%>'/></ItemTemplate><EditItemTemplate><asp:TextBoxID="tbDestroyYear"SkinID=tbrunat="server"ReadOnly=trueText='<%# Bind("date_dest_year")%>'/></EditItemTemplate></asp:TemplateField>

<asp:CommandFieldShowEditButton="True"/></Fields></asp:DetailsView><Triggers><atlas:ControlEventTriggerControlID="ddlScheduleType"EventName="SelectedIndexChanged"/></Triggers></contentTemplate>

</ajax:UpdatePanel>

</td></tr></table><asp:SqlDataSourceID="SqlDsMaster"runat="server"SelectCommand="select dr_id, box_barcode, box_description, box_location, status_name, box_site, site_name from view_dr_master where box_site not in(97,98)"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"></asp:SqlDataSource><asp:SqlDataSourceID="SqlDsDetail"runat="server"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"SelectCommand="SELECT dr_id, box_barcode, box_schedule_type, box_description, box_location, box_status, status_name, box_site, site_name, fiserv_dept, dept_name,

date_start, date_end, date_dest_month, date_dest_year, box_cardholder, box_cardholder_desc

FROM view_dr_master WHERE (dr_id = @dotnet.itags.org.dr_id)">

<SelectParameters><asp:ControlParameterControlID="gvDrMaster"Name="dr_id"PropertyName="SelectedValue"Type="String"/></SelectParameters></asp:SqlDataSource>

<asp:SQLDataSourceID="dsScheduleType"Runat="Server"SelectCommand="SELECT schedule_id, schedule_record_type from dr_schedule GROUP BY schedule_id, schedule_record_type Union Select 0 schedule_id, 'Please select a box category' schedule_record_type From dr_schedule ORDER BY schedule_record_type"DataSourceMode="DataSet"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"></asp:SQLDataSource><asp:SQLDataSourceID="dsStatus"Runat="Server"SelectCommand="SELECT status_id, status_name from dr_status Union Select '' status_id, 'Please select a box status.' status_name from dr_status ORDER BY status_id "DataSourceMode="DataSet"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"/><asp:SQLDataSourceID="dsSite"Runat="Server"SelectCommand="select site_id, site_name from dr_site order by site_id"DataSourceMode="DataSet"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"/><asp:SQLDataSourceID="SQLDSLocation"Runat="Server"DataSourceMode="DataSet"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"></asp:SQLDataSource>

<asp:SQLDataSourceID="SQLdsDepartment"Runat="Server"SelectCommand="select dept_id, dept_name from dr_departments"DataSourceMode="DataSet"ConnectionString="<%$ ConnectionStrings:RetentionConnectionString%>"/>

</

asp:Content>Dim dtDestroyDateAs DateTime = dtDestroyDate.AddDays(nDistroyDays)

ctrlTbDY.Text = dtDestroyDate.Year

ctrlTbDM.Text = dtDestroyDate.Month

EndSub

Never mind figured it out, removed

<Triggers><atlas:ControlEventTriggerControlID="ddlScheduleType"EventName="SelectedIndexChanged"/></Triggers>

DetailsView & Ajax Calender

Hi there,

I have a textbox within a DetailsView called txtDate, What I am trying to do is use the ajax extension to show a calender however whenever I try run the page I get an error telling me txtDate can not be found.

What do I need to do to enable this?


Any help would be great.

Thanks once again.


Shane

Can anyone point me in the right direction?

Saturday, March 24, 2012

Derived Textbox Not Recognized as Textbox

Hi All,

I have a derived text box class that inherits directly off of TextBox. I have this textbox on a page, and when I use the TextboxWatermark extender and set the TargetControlID to my textbox's ID Atlas doesn't seem to realize that it's a textbox, but just a control. We surmised this because the extender throws an error on "this.control.get_text();" while it's happy to execute "this.control_getCssClass();"

If I use a regular ASP textbox on the page, the extender is a happy camper. Anybody have any thoughts about this?

Thx.

I am having the same issue with the toolkit samples as well. Did you find a fix or reason for this? I also do not have any the properties available in the property box in VS2005 for any of the Atlas controls. But I can go to the source and enter the properties fine.

Dale


We haven't gotten an answer yet. I'm going to try another avenue and see if I get anywhere. I'll post any results.

Oh man, I can't believe I screwed that up. We added code that checks the type of the control being extended and then tweaks the generated XML type based on that so the client side can talk to the specific type (e.g. Sys.UI.TextBox instead of Sys.UI.Control). Well it looks in a hashtable based on the type of the control. So if they type isn't exact, the lookup fails. Darn.

Anyway, here's how to work around it. You just need to do a simple override of the TextboxWatermarkExtender. If VS starts complaining about the reference to ExtenderControlBase, click on "Microsoft.AtlasControlExtender" in your reference and change "Specific Version" to true. I'm not sure why mine got angry about that, but just in case you see it.

public class MyTextBox : System.Web.UI.WebControls.TextBox { }public class MyTextboxWaterMarkExtender : AtlasControlToolkit.TextBoxWatermarkExtender {protected override string GetClientClassForControl(System.Web.UI.Control control) {if (controlis System.Web.UI.WebControls.TextBox) {return"textBox"; }return base.GetClientClassForControl(control); } }

Hey Shawn,

Thanks for the work around. We'll get to testing it this afternoon.

It's a sweet toolkit and the bugs (aka job securitySmile [:)]) will get worked out.

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.

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

Default date selection, like a high-lighted box for ajaxToolkit:CalendarExtender

Hi,

Can we do this? Right now when the textbox is clicked, a calendar does pop-up with the sentence at the bottom - Today is - today's date - is there a way to select the day in month, having a blue box around it?

Thanks.

Do you mean have a default date selected in the calendar when the click in the textbox? If so, then Yes. There is aSelectedDate property you can set. You can also change the color to whatever you want using theCssClass="ClassName" and the.ajax__calendar_active property. Seehttp://www.asp.net/AJAX/AjaxControlToolkit/Samples/Calendar/Calendar.aspx for more info. If it is something else that you are trying to accomplish, let me know.

Bebandit