Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

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>

Saturday, March 24, 2012

Deployment on production server : Ajax does not function; on local WorkStation is Ok

Hello,

I have just put to me to the AJAX, I installed it well on my PC, my ajax project with "Update Panel" functions locally.

I put it in production, I put the extensions in [bin]: "AjaxControlToolkit.dll"; System.Web.Extension is quite present in the GAC and when I click on the button to refresh the "update panel" in which a label update yourself. a traditional PostBack of alll the page is carried out! as if there were no Ajax!!?

Help me!


En fran?ais :

Bonjour,

Je viens de me mettre à l'AJAX, je l'ai bien installé sur mon poste, mon projet ajax avec un Update Panel fonctionne en local.

Je le mets en production, j'ai mis les extensions dans [bin] :
"AjaxControlToolkit.dll", System.Web.Extension est bien présent dans le GAC

et quand je clique sur le bouton pour rafraichir l'update panel dans lequel un label se mets à jour. un rafraichissement classique de toute la page s'effectue! comme si il n'y avait pas d'Ajax!!?

un peu d'aide ne serait pas de refus!

The first think I will ask you is to make sure the same version of Ajax is installed on the production server. I know it may sound silly, but I know several people with similar problem and they claim that they have the same version, but when they take a deeper look, they notice that there was not the same.

Wednesday, March 21, 2012

Default atlas:UpdatePanel Default Behavior

I feel that the default behavior for an update panel should include disabling the content/controls it contains while an update is occuring (Make all the anchors turn into divs, disable all form inputs, etc.. etc..), or at least an option for toggling that functionality. Then the atlas:UpdateProgress could contain a cancel button that would re-enable the update panel's content. It seems to me that most people would expect that behavior and it would really help developers AJAX code be a little tighter.

hello.

hum...i think that you can do that by injecting javascript on the page during the events generated by the pagerequestmanager client class...another option would be to build an extender ;)


Well, I'm sure there are plenty of ways to do it; however, what I'm trying to say is it would be nice if either (A) it was the default behavior of an atlas:updatepanel while it is updating or (B) there was a property that could easily be set to accomplish this disableDuringUpdate="true" or something like that.

My reasoning is simply that I believe many people will end up writing that code themselves while one of the main goals of .NET seems to be to write less code and make it easier for a developer to produce results faster. I don't think it would be very difficult to include with the AJAX/Atlas extensions.

Declarative timer and web service

I am trying to use a declarative script to timer on tick -> web service on complete -> update label.

No problems with updating the label but is there anyway to invoke a service method without resorting to javascript (i.e. pure xml-script)? I imagine I can do something like tick="Sys.Net.ServiceMethod.invoke(..." but it kinda kills the purpose.

Any ideas?

Alex

hello.

i think you're after the servicemethodrequest class.

here's an example of it's declaration:

<serviceMethod id="myService" url="webservice.asmx" methodName="Test">
<completed>
<!--invoke your binding from here-->
</completed>
</serviceMethod>

btw, you can invoke the previous service by using the invokeMethod action (invoke is the name of the method exposed by servicemethod that let's you start the web service method execution).


Luis - yes I am after theServiceMethodRequest class except I would like to invoke the ws via a timer control (w/o resorting to using JS) on tick event:

<timer id="timer" interval="1000" enabled="true" tick="INVOKE WS"/
<serviceMethod id="svc..." url="service.asmx" methodName="GetSomething">
<completed> ...</completed>
</serviceMethod>

While I can write a JS function to invoke the method (and I have done this) I would like to create a version (more elegant) w/o any JS using declarative script. No point for me to use a combination of declarative script to do the binding and ws calls if I still have to write a JS function to call the ws on Tick, might as well do the bindings manually. Right now this is what I do but would be great if I can use the tick event to invoke a ws as well. Any ideas?

AO


hello.

how about something like this;

<timer ...>
<tick>
<invokeMethod target="svc..." method="invoke" />
</tick>
</timer>

if you need parameters, then add them as child element of the invokemethod element...


Thanks that was easy... wish there was an easy way to browse the Atlas library by class with Visual Studio. The documentation didn't make any mention of this (as far as I remember) and from briefly looking in the code I didn't find it.

Luis, thanks again!