Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Wednesday, March 28, 2012

Multiple PopupControlExtender - HOW?

Hi!

For example I have 10 textbox on my page. I created a panel with a calendar inside. I use 10 PopupControlExtender to bound the same panel to every textbox. (i dont want to create 10 diffrent Panels!)

And now i have a problem: How can i found out which PopupcontrolExtener and/or Textbox opend the calendar? I need this to set the value.

Any idea?

Thank you and sorry for bad english ;-)

Make it a user control. I've already done this and other than the issues that I've noted in some other posts about the popup behavior no longer working after postback, it works just fine. Below is the code I use to create the UserControl.

<%@. Control Language="C#" AutoEventWireup="true" CodeFile="DatePicker.ascx.cs" Inherits="User_Controls_DatePicker" %>
<asp:TextBox ID="tbDateSelected" runat="server" SkinID="DateTextBox"></asp:TextBox>
<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
<aspAjax:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<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>
<asp:ImageButton ID="imgCancel" runat="server" ImageUrl="../images/close.gif" OnClick="imgCancel_Click" />
</center>
</ContentTemplate>
</aspAjax:UpdatePanel>
</asp:Panel>
<ajaxToolkit:PopupControlExtender ID="pceDate" runat="server" PopupControlID="Panel1" TargetControlID="tbDateSelected" Position="Bottom" ></ajaxToolkit:PopupControlExtender>
<ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="Panel1" Radius="6" Opacity="1" TrackPosition="true" Width="5">
</ajaxToolkit:DropShadowExtender
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;
using AjaxControlToolkit;

public partial class User_Controls_DatePicker : System.Web.UI.UserControl
{
private string _selectedDate;

public string SelectedDate
{
get { return tbDateSelected.Text; }
set { tbDateSelected.Text = value; }
}

public string Position
{
set { pceDate.Position = ( PopupControlPopupPosition ) Enum.Parse( typeof( PopupControlPopupPosition ), value ); }
}

protected void Page_Load( object sender, EventArgs e )
{
}

protected void Calendar1_SelectionChanged( object sender, EventArgs e )
{
pceDate.Commit( Calendar1.SelectedDate.ToShortDateString( ) );
}
protected void imgCancel_Click( object sender, ImageClickEventArgs e )
{
pceDate.Cancel( );
}
}

Hope this helps.

Nick


You can find out which PopupControlExtender called the calendar with the info accessible by calling this following function, in the event handler for the control you popped up:

 
AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page)
You can use that in, say, your calendar's OnSelectedDateChanged event handler to see where it needs to go.

You can use the .Commit() function to submit the information from the calendar to the correct control. Once again, this would go in the event handler for your calendar's OnSelectedDateChanged event handler.

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).Commit(Calendar1.SelectedDate.toString())
 
Thanks toTed Glaza for the assist. 

Hello!

Thanks for your reply!

@.ncipollina
Thats not the right solution. I dont want to deliver 10 rendered controls (With the same content!) to the client. Thats to much overhead!

@.Matt M
Hi! That sounds interessting. But I dont get the point.

Protected Sub Calender_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim currentPopupControlExtender as AjaxControlToolkit.PopupControlExtender = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page)
currentPopupControlExtender.Commit(DirectCast(sender, Calendar).SelectedDate)
End Sub

Is this what you mean? I will try it tomorrow!


Undying:

Hello!

Thanks for your reply!

@.ncipollina
Thats not the right solution. I dont want to deliver 10 rendered controls (With the same content!) to the client. Thats to much overhead!

@.Matt M
Hi! That sounds interessting. But I dont get the point.

Protected Sub Calender_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim currentPopupControlExtender as AjaxControlToolkit.PopupControlExtender = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page)
currentPopupControlExtender.Commit(DirectCast(sender, Calendar).SelectedDate)
End Sub

Is this what you mean? I will try it tomorrow!

Use

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).TargetControlID
to find the TargetControlID of the PopupControlExtender that caused the panel to pop up. In other words, what textbox is the target of the PopupControlExtender.
 
Is that what you are looking for? 

Matt you are the man!

Protected

Sub Calender_SelectionChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(

Me).Commit(DirectCast(sender, Calendar).SelectedDate)EndSub

This work like a charme! I could use the Same "DatePickerPanel" on my page many times without duplicate code. Just add a Extender to the textbox and I'm done! Fine!

Thanks again for sharing this!


I am not sure that this actually works. I mean, the commit on the proxy works, but if I try to retrieve the value of TargetControlID from AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).TargetControlID, it is null (which sense since what is returned from the getproxy method is an empty popupcontrolextender)

Is there any way to retrieve this information? I am trying to set the value of two textboxes, each based on the other and another arbittrary value...

i.e. - i would like my code to be soomething like:

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).Commit(calendar1.selecteddate.tostring())

select case AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).TargetControlID

case "text1"

text2.text=format(calendar1.selecteddate.addmonths(arbitrary value),"MM/dd/yyyy")

case "text2"

text1.text=format(calendar1.selecteddate.addmonths(-1*arbitrary value),"MM/dd/yyyy")

end select


Could you pleaseopen a work item to report and track this issue. Thank you!

multiple ScriptManagers on a page

hi there; i've created the following page:

<%@dotnet.itags.org.PageLanguage="VB"MaintainScrollPositionOnPostback="true"AutoEventWireup="true"EnableEventValidation="false" %>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN"> <htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Welcome</title>

<scriptlanguage="VB"runat="server">

ProtectedSub RedirectUser(ByVal senderAs System.Object,ByVal eAs System.EventArgs)

Dim tempID = ddlTemp.SelectedItem.Value

Response.Redirect("default.aspx?tempID=" & tempID)

EndSub

</script>

</head>

<body>

<formid="frm"defaultfocus="txtTemp"runat="server">

<atlas:ScriptManagerID="ScriptManager1"runat="server"/>

<divclass="index"> <center>

<tablewidth="100%"height="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<td>

<divstyle="width:615px; text-align:left;">

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasToolkit:CascadingDropDownPropertiesLoadingText="Loading"Category="B"TargetControlID="ddlB"

ServiceMethod="GetB"ServicePath="WebService.asmx"PromptText="Please select"/>

<atlasToolkit:CascadingDropDownPropertiesCategory="A"TargetControlID="ddlA"

ParentControlID="ddlB"LoadingText="Loading"ServiceMethod="GetA"ServicePath="WebService.asmx"

PromptText="Please select"/>

</atlasToolkit:CascadingDropDown>

<asp:DropDownListID="ddlB"runat="server"/>

<asp:DropDownListID="ddlA"AutoPostBack="true"OnSelectedIndexChanged="RedirectUser"runat="server"/>

<divstyle="margin-top:25px;">

<asp:TextBoxID="txtTemp"runat="server"></asp:TextBox>

<asp:ButtonID="cmdFindTemp"CssClass="submit"UseSubmitBehavior="false"OnClientClick="this.disabled = true; this.value = 'Submitting...';"runat="server"PostBackUrl="default.aspx"Text="Go!"/>

<atlas:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server">

<atlas:AutoCompletePropertiesServicePath="WebService.asmx"ServiceMethod="GetTemp"TargetControlID="txtTemp"Enabled="true"MinimumPrefixLength="1"/></atlas:AutoCompleteExtender>

</div>

</div>

</td>

</tr>

</table>

</center>

</div>

</form> </body>

</html>

this page basically displays a couple of dropdown lists, a textbox and a submit button.

as you can see, i'm using the atlas control and the atlas toolkit control.

to make the controls function, i'm using the atlas:Scriptmanager.

using asp:scriptmanager (instead of an atlas:Scriptmanager) causes my page to crash with the following error message:

Extender controls require a ScriptManager to be present on the page.
Parameter name: scriptManager

what's worse is that if i try to add an ajaxToolkit control, such as:

<ajaxToolkit:TextBoxWatermarkExtenderID="TextBoxWatermarkExtender1"runat="server"TargetControlID="txtTemp"WatermarkText="Type Name Here"WatermarkCssClass="watermarked"></ajaxToolkit:TextBoxWatermarkExtender>

then i get the following error:

The control with ID 'TextBoxWatermarkExtender1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

well, the atlas:ScriptManager is before it and, again, i still get an error if i try using the asp:ScriptManager.

my question is, how many different scriptmanager's are there and what can i use that cover's all controls (i.e. ajax, ajaxToolbarKit, atlasToolbarKit)

thanks all.

Hi Chubbs,

Your problem is caused by the confilict between Atlas(previous version of Asp.Net Ajax Extension) and Asp.Net Ajax Extension. Ajax ControlToolkit works depend on Asp.Net Ajax Extension 1.0. So why not convert your application from "Atals" to "Asp.Net AJAX RTM" since it is more powerful and stable. It is recommended to update your Asp.Net Ajax Extension and Ajax ControlToolkit to the latest version.

Here is the way: http://ajax.asp.net/documentation/Migration_Guide_CTP_to_RTM.aspx

By can download the lastest released version here:http://ajax.asp.net/downloads/default.aspx?tabid=47

Hope it helps.


hi, jonathan; thanks for the response.

well, it took me several hours to tweak and work out the ensuing glitches, but it finally paid off. much cleaner now.

anyway, for the benefit of those who have the same issue, i will post my final working code.

basically, i have 2 cascading dropdowns that each receive their data from a database.

DROPDOWN.ASPX

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

<%@.PageLanguage="VB"MaintainScrollPositionOnPostback="true"AutoEventWireup="true"EnableEventValidation="false" %>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Cascading Drop Down</title>

<scriptlanguage="VB"runat="server">

</script>

<linkhref="styles.css"rel="stylesheet"type="text/css"/>

</head>

<bodyclass="index">

<formid="frmIndex"defaultfocus="txtCompany"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server"/>

<divid="index">

<center>

<tablewidth="100%"height="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<td>

<divstyle="width:630px; text-align:right;">

<ajaxToolkit:CascadingDropDown

LoadingText="Loading Provinces"

Category="Province"

ID="CascadingDropDown1"

TargetControlID="ddlProvince"

ServiceMethod="GetProvinces"

ServicePath="WebService.asmx"

PromptText="Please select a province"

runat="server"/>

<ajaxToolkit:CascadingDropDown

LoadingText="Loading Cities"

ParentControlID="ddlProvince"

Category="City"

ID="CascadingDropDown2"

TargetControlID="ddlCity"

ServiceMethod="GetCities"

ServicePath="WebService.asmx"

PromptText="Please select a city"

runat="server"/>

<asp:DropDownListID="ddlProvince"runat="server"/>

<asp:DropDownListID="ddlCity"AutoPostBack="true"OnSelectedIndexChanged="RedirectUser"runat="server"/>

</div>

</td></tr>

</table>

</center>

</div>

</form>

</body>

</html>

WEBSERVICE.VB

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

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Collections.Generic

Imports AjaxControlToolkit

Imports System.Data

Imports System.Data.SqlClient

Imports System.Collections

Imports System.Collections.Specialized<WebService(Namespace:="http://tempuri.org")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

<System.Web.Script.Services.ScriptService()> _

PublicClass WebServiceInherits System.Web.Services.WebService

<WebMethod()> _

PublicFunction GetProvinces(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As AjaxControlToolkit.CascadingDropDownNameValue()

Dim valuesAsNew System.Collections.Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

Dim myDatasetAs DataSet

myDataset = HttpContext.Current.Cache("tblProvince")

If myDatasetIsNothingThen

Dim myConnectionAsNew SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)

Dim myCommandAsNew SqlCommand("SELECT * FROM tblProvince", myConnection)

Dim myAdapterAsNew SqlDataAdapter(myCommand)

myDataset =New DataSet

myAdapter.Fill(myDataset)

HttpContext.Current.Cache.Insert("tblProvince", myDataset)

Else

myDataset =CType(HttpContext.Current.Cache("tblProvince"), DataSet)

EndIf

ForEach rowAs DataRowIn myDataset.Tables(0).Rows

values.Add(New CascadingDropDownNameValue(row("fldProvince"), row("fldProvinceID")))

Next

Return values.ToArray

EndFunction

<WebMethod()> _

PublicFunction GetCities(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()

Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

IfNot (kv.ContainsKey("Province"))Then

ReturnNothing

EndIf

Dim valuesAsNew System.Collections.Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

Dim myConnectionAsNew SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)

Dim strSQLAsString ="SELECT * FROM tblCity WHERE (tblCity.fldProvinceID='" & kv("Province") &"')"

Dim myCommandAsNew SqlCommand(strSQL, myConnection)

Dim myAdapterAsNew SqlDataAdapter(myCommand)

Dim myDatasetAsNew DataSet

myAdapter.Fill(myDataset)

ForEach rowAs DataRowIn myDataset.Tables(0).Rows

values.Add(New CascadingDropDownNameValue(row("fldCity"), row("fldCityID")))

Next

Return values.ToArrayEndFunction

EndClass

WEB.CONFIG

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

<?xmlversion="1.0"?>

<configuration>

<configSections>

<sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>

<sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="Everywhere" />

<sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication" />

<sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication" />

</sectionGroup>

</sectionGroup>

</sectionGroup>

</configSections>

<connectionStrings>

<addname="myConnectionString"connectionString="Data Source={SQLServer};Server=yourServer;Database=yourDatabase;Uid=yourID;Pwd=yourPassword;"/>

</connectionStrings>

<system.web>

<pages>

<controls>

<addnamespace="System.Web.UI"tagPrefix="asp"assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addnamespace="AjaxControlToolkit"assembly="AjaxControlToolkit"tagPrefix="ajaxToolkit"/>

<addnamespace="AtlasControlToolkit"assembly="AtlasControlToolkit"tagPrefix="atlasToolkit"/>

<addnamespace="System.Data"tagPrefix="asp"/>

<addnamespace="System.Data.SQLClient"tagPrefix="asp"/>

</controls></pages>

<compilationdebug="true">

<buildProviders>

<addextension=".asbx"type="Microsoft.Web.Services.BridgeBuildProvider"/>

</buildProviders>

<assemblies>

<addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

<addassembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>

<httpHandlers>

<removeverb="*"path="*.asmx"/>

<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/></httpHandlers>

<customErrorsmode="Off"/>

<httpModules>

<addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</httpModules>

</system.web>

<system.web.extensions>

<scripting>

<webServices>

<!-- Uncomment this line to customize maxJsonLength and add a custom converter-->

<!--

<jsonSerialization maxJsonLength="500">

<converters>

<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>

</converters>

</jsonSerialization>

-->

<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.-->

<!--

<authenticationService enabled="true" requireSSL = "true|false"/>

--><!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved

and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and

writeAccessProperties attributes.-->

<!--

<profileService enabled="true"

readAccessProperties="propertyname1,propertyname2"

writeAccessProperties="propertyname1,propertyname2" />

-->

</webServices>

</scripting></system.web.extensions>

<system.webServer>

<validationvalidateIntegratedModeConfiguration="false"/>

<modules>

<addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</modules>

<handlers>

<removename="WebServiceHandlerFactory-ISAPI-2.0"/>

<addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

</handlers>

</system.webServer>

</configuration>

Well, there it is in it's entirety. Hopefully this will help someone get up and running with this control in the future.

Good luck!

Multiple Update Panels & Control Events

Thankfully i've been able to re-create this issue but i'm still not entirely sure why it happens as it does. I've created a page with two update panels, inside of each is a label and a button. Each label is set to the current date when the labels PreRender event fires. The first time this loads, each event fires at pretty much the same time. As expected if i press either of the buttons, both label PreRender events fire and update the corresponding label. However If i set the update mode to conditional on the updatepanel, both labels PreRender events fire but only the one which shares the update panel with the pressed button has the UI updated. In this trivial example thats not too much of a problem, however when I'm loading in a dataset in one of the panels, i dont want the data being re-loaded in each time a different update panel posts back. Thanks in advance, Matt Here's my trivial example HTML and C# c#
protected void Page_Load(object sender, EventArgs e) { }protected void Label1_PreRender(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); }protected void Label2_PreRender(object sender, EventArgs e) { Label2.Text = DateTime.Now.ToString(); }protected void Button2_Click(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) { }
<asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" OnPreRender="Label2_PreRender" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit 2" /> </ContentTemplate> </asp:UpdatePanel> </div> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" OnPreRender="Label1_PreRender" Text="Label"></asp:Label> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Submit One" /> </ContentTemplate> </asp:UpdatePanel>

This is by design. When you have multiple UpdatePanels and each set to Conditional, UI updates only occur in that particular UpdatePanel. You can get more info about UpdatePanels in the docs:http://www.asp.net/AJAX/Documentation/Live/tutorials/UpdatePanelTutorials.aspx

For updating a label like you are, I would utilize PageMethods vs. and UpdatePanel anyway. You can mix the two technologies if you need to. Seehttp://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous for an excellent example and more information.

-Damien

Multiple updatepanels and updateprogress

Hi,

I have created two updatepanels with a button and a label in each panel. Both panels are associated to a updateprogress. When I click the button I simle add datetime.now to the label. I also use thread.sleep for some seconds. This is a basic asp.net ajax example. But my question is: when I click the first button and thereafter click the second button when the first one is at sleep. In this case the second updateprogress starts working and I get the date in the second label. How can I manage to implement two asynchronous calls at the same time? i.e. I want to press both buttons and get two dates in each label.

You can't execute two partial postbacks simultaneously.

In InitializeRequest, you can use PageRequestManager.get_isInAsyncPostBack() to test for an already running partial postback and respond accordingly.


Ok, thank you. My question is answered!

Monday, March 26, 2012

My extender control wires its events, then seems to forget what it is!

I've created an extender using the Ajax Extender Control Template. It takes a TextBox as its TargetControl and adds a couple of drop downs to its child controls. Then it responds to the onblur event of the text box. It is supposed to set the values of the drop downs before it posts back. The problem is that when the text box fires its 'blur' event I can't use the 'this' keyword to refer to any of the classes properties or methods. Here is a brief snippett:

Company.Web.MASW.ProductAutoCompleteBehavior.prototype = { initialize : function() { Company.Web.MASW.ProductAutoCompleteBehavior.callBaseMethod(this,'initialize'); $addHandler(this.get_element(),'blur',this._elementChanged ); $addHandler(this._DiameterElement,'click',this._setElementValue ); $addHandler(this._TypeElement,'click',this._setElementValue ); },... _elementChanged : function(e) { alert(this.get_element()); }, _setElementValue : function(e) { alert( this._DiameterElement ); }}
 

The alert commands just verify that I've managed to make the connection to the right input element. It should pop up and say [object] but I get a script error saying object does not support this property or method. I just can't understand how it's calling the right event but can't see it's own properties. Could It be that it's inheriting from the AjaxToolkit.BehaviorBase class?

It seems as though I have a lot to learn about how to connect everything in Ajax. I've done a fair amout of JavaScript and I've done a fair amount of JScript in ASP. I have got a lot to learn about how Ajax connects ECMA, EMCA, E=MC2, or what ever it's called. I just can't fool with it much more for now so consider this 'resolved'. Thanks to all those who read this and said "what in the world is he up to?"

Saturday, March 24, 2012

My masterpage still flickers!

I'm using masterpages. Here's the layout of the masterpage:

Top - Menu

Middle - Content

Right - gridview

The Problem:

I created a search control that simply does a customer locate. I dropped the control on an aspx page and added a button under the control that is used to load the selected row to the griview on the masterpage. When I click the button the row is added fine, but the screen is not acting atkas-like...it reloads.

I defined my scriptmanager on the masterpage. And I've tried the following 3 scenerios to make this work the "Atlas" way...to no avail.

1) Placing the updatepanel within the control itself, and referencing the button's click event using a <Trigger>.

2) Wrapping the entire control and button with an update panel.

3) Wrapping the control with an updatepanel, and referencing the button's click event using a <Trigger>.

I'm either doing something wrong, or this cannot be done using Atlas. Can updating a gridview on a masterpage from within a content page be done using Atlas?

Eric

Something simple first. Did you set

EnablePartialRendering

="true"

for the script manager?


based on my experience (coz I implemented this atlas on my site) and based on the videos given by this site, i setup this atlas this way:

1. my script manager is not in the masterpage. i put it on the aspx page.
2. i put the trigger control (like button) outside the updatepanel, or you can put it on a different updatepanel if necessary.

so far this setup works with me. no flicker.Smile

Enablepartialrendering is true.

I'll try moving the scriptmanager to inside the acsx...thanks for the advice.


Ok...I moved the scriptmanager to the aspx page, and added the trigger. But doing it that way results in an asynch postback, but there is no rendering of the gridview on the masterpage.

Any ideas?


i am not sure what's really happening with your proj but my site has 2 gridviews that talks to one another but I did not encouter the issue you have now. Try to setup the atlas controls again starting from zero and this time put the script manager in the aspx page.
I rebuilt the project with the same result. I guess i'll just live with the anomoly for now. thanks.
just a question. why do u have to wrap the buttons with the updatepanel? does your button need to do something after the postback? if not, free up the button.
try isolation test. apply atlas on controls (where necessary) one after another until you see where the problem lies.

I have tried the button within the updatepanel, and oustside of the updatepanel (referencing the button with trigger). I think i understand where the problem is, i just don't think it will work. The control is wrapped in an updatepanel, The button exists on the same page that i dropped the ascx control on, as does the scriptmanager. By clicking the button I wish to send the selected row to a grid that exists on the masterpage. When i wrap that grid with an updatepanel i get "cannot use an updatepanel without a scriptmanager error. When i drop a scriptmanager on the masterpage i get "cannot have 2 sciptmanagers" error. When i remove the scripmanger on the aspx page the the ascx is on, nothing is displayed in the grid. argghhh.

BTW, i really don't want to have the scriptmanager existing in the masterpage.

If you have an example of how you can get this situation to work it would be priceless.


i recommend the same. isolation test lets you see where the problem lies.
i'm confused as why a moderator set this post as "answered"... i do not see any semblence of a "that fixed my problem and it works now" yet in this topic, so how is it "answered" ?

hello.

if you can build a small demo project that reproduces , then this i wouldn't mind taking a look at it to see if i can understand what's going on...

Wednesday, March 21, 2012

need help for UpdatePanel

Hi

I created one page with AJAX.Net. My page is as follow. It is working fine. but When I click on Save button It save the data into the database and reset the Controls value[using ResetControls() methods]. this method is fired but it is not reset the controls value. I do not know why? Can Any body help me? I put my .aspx and Save button event.

<

asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"></asp:ScriptManager>

<

asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>

<tablecellspacing="0"cellpadding="2"width="97%"border="0"align="center">
<tr><tdalign="right"style="height: 28px"width="18%"></td><tdstyle="height: 28px"width="2%"></td><tdclass="ItemDetail"style="height: 28px"width="80%">
<asp:LabelID="lblMessage"runat="server"SkinID="errorLable"></asp:Label></td></tr></table>

</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTriggerControlID="btnSave"EventName="Click"/>
</Triggers>

</asp:UpdatePanel>

<tablecellspacing="0"cellpadding="2"width="97%"border="0"align="center">
<tr><tdwidth="18%"style="height: 28px"align="right"><asp:LabelID="lblDate"runat="server"Text="Date"SkinID="requiredLabel"></asp:Label></td>
<tdwidth="2%"style="height: 28px"> </td><tdwidth="80%"class="ItemDetail"style="height: 28px">
<asp:TextBoxID="txtDate"runat="server"Columns="15"MaxLength="12"></asp:TextBox>
<asp:Imagerunat="Server"ID="Image1"ImageUrl="~/images/cal.gif"ToolTip="Click to show calendar"style="border-width:0px;"DescriptionUrl="#"/>
<cc1:CalendarExtenderID="CalendarExtender1"runat="server"Format="MMMM d, yyyy"TargetControlID="txtDate"BehaviorID="CalendarExtender1"PopupButtonID="image1">
</cc1:CalendarExtender>
</td></tr><tr><tdalign="right"><asp:LabelID="lblSpeaker"runat="server"Text="Speaker"SkinID="requiredLabel"></asp:Label></td><td> </td><tdclass="ItemDetail">
<asp:TextBoxID="txtSpeakerName"runat="server"Columns="30"MaxLength="50"></asp:TextBox></td></tr>

<tr><tdalign="right"><asp:LabelID="lblTopic"runat="server"Text="Topic"></asp:Label> </td><td> </td><tdclass="ItemDetail">
<asp:TextBoxID="txtTopic"runat="server"Columns="45"MaxLength="100"></asp:TextBox></td></tr
<tr><tdvalign="top"align="right"><asp:LabelID="lblComments"runat="server"Text="Comments"></asp:Label> </td><td> </td><tdclass="ItemDetail">
<tablecellpadding="2"cellspacing="0"border="0"><tr><td>
<FTB:FreeTextBoxID="txtComments"runat="server"AllowHtmlMode="True"BreakMode="LineBreak"
ButtonSet="OfficeXP"ConvertHtmlSymbolsToHtmlCodes="True"DisableIEBackButton="True"Height="175px"SupportFolder="/CRRoot/FreeTextBox/"ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertRule|Cut,Copy,Paste;Undo,Redo,Print,InsertImageFromGallery"></FTB:FreeTextBox> </td></tr></table></td></tr
<tr><tdclass="ItemHeading"valign="top"align="right"></td><td></td><tdclass="ItemDetail"></td></tr
<tr><tdcolspan="3"class="CommandBar"> <asp:ButtonID="btnSave"runat="server"Text=" Save "OnClick="btnSave_Click"AccessKey="S"/>
<asp:ButtonID="btnCancel"runat="server"Text=" Cancel "CausesValidation="False"OnClick="btnCancel_Click1"AccessKey="C"/></td></tr
</table
===============================

protectedvoid btnSave_Click(object sender,EventArgs e){

string Errors = validation();
if (Errors.Length > 0)
{
lblMessage.Text = Errors;
lblMessage.Visible =true;
return;}DateTime SpeakerDate =DateTime.Today;
DateTime.TryParse(txtDate.Text.Trim(),out SpeakerDate);
string SpeakerName = txtSpeakerName.Text.Trim();
string Topic = txtTopic.Text.Trim();
string Comments = txtComments.Text.Trim();
string Action = ((Utilities.ProcessStatus)this.ProcessMode).ToString();
int Success =Speaker.SpeakerAddEditDelete(CookiesInfo.ClubId,this.SpeakerId, SpeakerDate,
SpeakerName, Topic, Comments, Action);
if (Success == -1)
{
lblMessage.Text =" - Record has not been saved. Please check the inputs.";
lblMessage.Visible =true;
}else{
ResetControls();
lblMessage.Text =" - Record has been saved successfully.";
lblMessage.Visible =true;
}
}privatevoid ResetControls(){

txtDate.Text =String.Format("{0:MMMM d, yyyy}",DateTime.Today);
txtSpeakerName.Text =string.Empty;
txtComments.Text =string.Empty;
txtTopic.Text =string.Empty;

}

The textboxes are not part of the UpdatePanel's ContentTemplate.

hence , inaccessible from the server.

Move them inside the UpdatePanel and they will be accessible .

Hope this helps

Need help using CollapsiblePanel

I tried looking at the sample website page and doing a search on the forums here.

I created a panel, put the panel in an updatepanel. but the collapsiblepanelextender inside the updatepanel as well. I set some overflow:hidden value on the style of the panel.

I load the page, I see the panel, then eventually it goes away, ok well that sucks anyway.

now what? I tried to create a button that would collapse/expand the panel but I'm not sure how.

I'm coding in VB and I looked at the C# sample web page and don't even see how they did it. All I see is if page is not postback, set panel to false and height to 0.

How do I control the collpasing and expanding with a button or whatever?

I tried on my button click but this but didn't work.

Protected

Sub Button1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Button1.Click
Dim TargetPanelPropertiesAs AtlasControlToolkit.CollapsiblePanelProperties = CollapsiblePanelExtender1.GetTargetProperties(AddMemberPanel)If TargetPanelProperties.Collapsed =FalseThen
TargetPanelProperties.Collapsed =True
ElseIf TargetPanelProperties.Collapsed =TrueThen
TargetPanelProperties.Collapsed =False
EndIfEndSub

Ok, I got it somewhat working. I took out the code and pointed the property some controlID to my button. Wierd thing is though,

When I click my button it shows, but when I roll-over the panel it collapses again. Also when the page first loads it doesnt' collapse until I roll over it. what the hell?


Hi Mastro,

I'm not sure what you're doing wrong from your decsription. Perhaps you could post afull code sample.

Thanks,
Ted

Need Help with Modal Popup!

Here's the deal...

I have a bound DetailsView (user control) that I have created custom command buttons for (add, edit, save, cancel).

Upon edit, I am storing the values for each field to hidden textboxes on the form. Upon save, I will need to run custom validation routine(s), as well as, compare old vs. new values (some changes will trigger back-end processes to kick off via SQL triggers and we want alert the user of this up front).

Once validation passes, if one or more of the values have changed that will cause execution of the triggers, I want to manually launch a popup [ modalpopup1.show() ] that lists the specific changes and asks the user to Confirm (ie., "Are they sure they want to Save?"). If so, the app will proceed with updating / saving the record and the SQL proc will go ahead and execute. If not, the update is cancelled and the detailsview goes back into read only mode.

Problem I am having is that the Modal wants me to specify a "TargetControlId" and I am not sure what that control should be. I tried making it the Save button, but doing so will cause the modal to appear immediately (ie., before the validations and old vs. new compare routine) executes. So I then tried creating a dummy button, but get the following error message: "The control 'btn_Dummy' already has a data item registered. Parameter name: control".

Can anyone help me on the proper way to code / implement this ?

Hi ,

The "TargetControlId" specifies the Control which will trigger the ModalPopup to Show .

What you can do is .. Once you come to know that certain changes have been made to the data , you can use the Client side methods of the ModalPopup to Show / Hide

Show and Hide ModalPopupExtender from JavaScript

Let me know if I missed anything


I tried this via example provided via thread ("Show Popup Dynamically via js") , but I really would like to popup the modal from another button's code behind (ie., after all my validations checks have been completed). Is there not a way to do this?

If not, I guess the only alternative would be to re-write the validation routines in js and call the popup from there??


From ServerSide , you have access to the ModalPopup's Show method using

ModalPopupExtender1.Show()

From Client side , use the method described in my previous reply.


Hi,

Still getting error message "data item already registered" when attempting to use ModalPopupExtender1.show().

Found thishttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7115 after doing more research on Google. It appears to be a bug.

Appreciate your trying to help. I've decide to manually hide / unhide my panels instead of the AJAX control until the above is resolved.

Thanks,

Annette