Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Wednesday, March 28, 2012

Update Trigger and GridView problem

Hi!

I have an Accordion on my page. In one AccordionPane, i have an UpdatePanel containing a GridView and a button under. When i try to access my gridview in the code-behind, i encounter a problem. The trigger of my button doesn't work, the method associated with my button isn't called. If i click a second time and the button, it postback my page and i lose all the data and the page. if i click a third time, the trigger associated with the button finally works.

I only get this problem when i try to access my GridView in my page.

I add my code and underlined the line which causes the problem, i remove it everythin works fine

aspx file:

<asp:UpdatePanelID="UpdatePanelGridStartSecurities"runat="server"UpdateMode="Conditional"ChildrenAsTriggers="false">

<ContentTemplate>

<divclass="ContentPaneDetails">

<%-- GridView : Supports de depart--%>

<divclass="ContentPaneElement">

<asp:GridViewID="GridViewGainOption_StartSecurities"runat="server"AutoGenerateColumns="false"BackColor="White"

BorderStyle="None">

<Columns>

<%-- Inclure --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_Include">

Include

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:RadioButtonID="GainOption_Include"runat="server"BackColor="ActiveCaptionText"GroupName="IncludeExclude"

Checked='<%# ((bool)DataBinder.Eval(Container.DataItem, "IsExcluded"))?false:true %>'/>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"HorizontalAlign="Center"/>

</asp:TemplateField>

<%-- Exclure --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_Exclude">

Exclude

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:RadioButtonID="GainOption_Exclude"runat="server"BackColor="ActiveCaptionText"GroupName="IncludeExclude"

Checked='<%# DataBinder.Eval(Container.DataItem, "IsExcluded") %>'/>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"HorizontalAlign="Center"/>

</asp:TemplateField>

<%-- Valeur mobilière --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_SecurityName">

Valeur mobilière

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:TextBoxID="GainOption_SecurityName"runat="server"BorderStyle="None"Text='<%# GetSecurityName(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SecurityId"))) %>'></asp:TextBox>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"/>

</asp:TemplateField>

<%-- Isin Code --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="GainOption_IsinCode">

Isin

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:TextBoxID="GainOption_IsinCode"runat="server"BorderStyle="None"Text='<%# GetIsinCode(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SecurityId"))) %>'></asp:TextBox>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"/>

</asp:TemplateField>

<%-- Seuil --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_Threshold">

Seuil %

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:TextBoxID="GainOption_Threshold"runat="server"BorderStyle="None"Text='<%# DataBinder.Eval(Container.DataItem, "TriggerringThreshold") %>'></asp:TextBox>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"/>

</asp:TemplateField>

<%-- Supprimer --%>

<asp:TemplateField>

<HeaderTemplate>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:LinkButtonID="GainOption_Delete"runat="server"CommandName="Delete">Supprimer</asp:LinkButton>

</ItemTemplate>

<ItemStyleBackColor="#D5DAE0"BorderStyle="None"/>

</asp:TemplateField>

</Columns>

</asp:GridView>

</div>

</div>

<divclass="ContentPaneDetails">

<divclass="ContentPaneElement">

<%-- Ajouter un nouveau support de départ --%>

<asp:LinkButtonID="GainOption_AddStartSecurity"runat="server"Text="Ajouter une valeur"OnClick="GainOption_AddStartSecurity_Click">

</asp:LinkButton>

<br/>

<%-- Nom du support --%>

<asp:LabelID="LbGainOption_StartSecurityName"runat="server"Visible="false"Text="Valeur moblière :"></asp:Label>

<asp:TextBoxID="GainOption_StartSecurityName"runat="server"Visible="false"></asp:TextBox>

<asp:ImageButtonID="ImgGainOption_StartSecurityName"runat="server"ImageUrl="~/Images/Directory.gif"Visible="false"/>

<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteGainOption_StartSecurityName"runat="server"TargetControlID="GainOption_StartSecurityName"

ServicePath="WebServices/AutoComplete.asmx"ServiceMethod="GetSecuritiesListByLongName"CompletionSetCount="3"MinimumPrefixLength="3"

CompletionListCssClass="autocomplete_completionListElement"CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"UseKeyValuePairs="true"

KeyHiddenFieldID="HiddenModify_SecurityId">

</ajaxToolkit:AutoCompleteExtender>

<%-- Isin du support --%>

<asp:LabelID="LbGainOption_StartIsinCode"runat="server"Visible="false"Text="Isin : "></asp:Label>

<asp:TextBoxID="GainOption_StartIsinCode"runat="server"Visible="false"></asp:TextBox>

<asp:ImageButtonID="ImgGainOption_StartIsinCode"runat="server"ImageUrl="~/Images/Directory.gif"Visible="false"/>

<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteGainOption_StartIsinCode"runat="server"TargetControlID="GainOption_StartIsinCode"

ServicePath="WebServices/AutoComplete.asmx"ServiceMethod="GetSecuritiesListByIsinCode"CompletionSetCount="3"MinimumPrefixLength="3"

CompletionListCssClass="autocomplete_completionListElement"CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"UseKeyValuePairs="true"

KeyHiddenFieldID="HiddenModify_SecurityId">

</ajaxToolkit:AutoCompleteExtender>

<%-- Seuil du support --%>

<asp:LabelID="LbGainOption_StartThreshold"runat="server"Visible="false"Text="Seuil : "></asp:Label>

<asp:TextBoxID="GainOption_StartThreshold"runat="server"Visible="false"></asp:TextBox>

<%-- Insert --%>

<asp:LinkButtonID="InsertGainOption_StartSecurity"runat="server"Visible="false"Text="Insert"OnClick="InsertFromSecurity_Click"></asp:LinkButton>

</div>

<divclass="Clear">

</div>

</div>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="GainOption_AddStartSecurity"EventName="Click"/>

<asp:AsyncPostBackTriggerControlID="InsertGainOption_StartSecurity"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

cs file:

protectedvoid Page_Load(object sender,EventArgs e)

{

if (IsPostBack ==false)

{

HiddenModify_NavigationMode.Value ="1";

//HiddenModify_NavigationMode.Value = "2";

//HiddenModify_MonitoringMandateId.Value = "7";

LogicMonitoringMandates monitorings =LogicMonitoringMandates.getInstance();

LogicGainMandateOptions gainOptions =LogicGainMandateOptions.getInstance();

LogicLossMandateOptions lossOptions =LogicLossMandateOptions.getInstance();

LogicSellMandateOptionDetails sellDetails =LogicSellMandateOptionDetails.getInstance();

LogicBuyMandateOptionDetails buyDetails =LogicBuyMandateOptionDetails.getInstance();

LogicPortfolios portfolios =LogicPortfolios.getInstance();

LogicSecurities securities =LogicSecurities.getInstance();

LogicPortfolioPositions positions =LogicPortfolioPositions.getInstance();

LogicPortfolioPositionDetails details =LogicPortfolioPositionDetails.getInstance();

securities.GetSecurities();

if (HiddenModify_NavigationMode.Value =="1")

{

/*

RadioButton gainOption_AutomaticPerimeter = (RadioButton)AccordionPaneGainOption.FindControl("GainOption_AutomaticPerimeter");

RadioButton gainOption_00007Threshold = (RadioButton)AccordionPaneGainOption.FindControl("GainOption_00007Threshold");

gainOption_AutomaticPerimeter.Checked = true;

gainOption_00007Threshold.Checked = true;

*/

}

if (HiddenModify_NavigationMode.Value =="2")

{

int l_intMonitoringMandateId =Convert.ToInt32(HiddenModify_MonitoringMandateId.Value);

monitorings.GetMonitoringMandateByMonitoringMandateId(l_intMonitoringMandateId);

gainOptions.GetMandateOptionsByMonitoringMandateId(l_intMonitoringMandateId);

HiddenModify_GainMandateOptionId.Value =Convert.ToString(gainOptions.GetMandateOptionFromIndex(0).MandateOptionId);

GridView gridViewGainOption_StartSecurities = (GridView)AccordionPaneGainOption.FindControl("GridViewGainOption_StartSecurities");

The problem comes if I add the line above

//sellDetails.GetMandateOptionDetailsByMandateOptionId(Convert.ToInt32(HiddenModify_GainMandateOptionId.Value));

//gridViewGainOption_StartSecurities.DataSource = sellDetails.TABLE;

//gridViewGainOption_StartSecurities.DataBind();

AccordionPaneSignaletique_DataBind();

AccordionPaneGainOption_DataBind();

}

}

}

Does anyone know what i can do? Can i add the trigger of the updatePanel in the code behind in the pageload method ?

Thanks in advance,

I've been looking for this problem for all my weekend and i found what was the problem!!!!!!!

The problem comes from the Accordion component, during the Page_Load, the Accordion and the child component doesn't exists, but in my case i didn't get any error of "not found controls".

I found a fix on this page :

http://couldbedone.blogspot.com/2007/07/what-wrong-with-accordion-control.html

Thanks a lot to this guy!

i just added Accordion.FindControl("nothing") on a Page_Init and it works great now!

UpdatePanel - DataGrid - Client Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

hello.

an easy way to do this is to add a dummy button and then perform a click programatically on that button. this should be enough to force the postback. you can also take a look at the postbackaction or event call the _dopostback method directly.


That Works fine
Thanks Madeira  
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

That Works fine
Thanks Luis Abreu
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

Does this only work from within the update panel?

I'm trying it from outside the panel and it is refreshing the whole page.

UpdatePanel - Javascript Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

I think this is possible. I've got the initial idea fromhere.
So put a hidden div into the UpdatePanel, for example:

<div style="display:none;">
<asp:Button id="btnHidden" runat="server" OnClick="btnHidden_Click" UseSubmitBehavior="false" /></div>

Then "trigger" this button in your popup window from javascript:

var refreshHelper = window.opener.document.getElementById( "btnHidden" );
refreshHelper.click( );

It works for me, but maybe there is smarter solutions than this.

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.


Luis Abreu:

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.

Luis (or anyone else), can you provide an example of using postback action? I'm trying to accomplish something very similar and the dummy button approach doesn't appeal to me.

-Lee


hello.

well, the dopostback action (or, if you want to use javascript, the __doPostBack method) will only work out correctly if there's a control placed inside the form which will be considered responsible for the postback.


Hi Luis,

I do have a a DropDownList that is inside the form so I that would work. I suppose I could just call the __doPostPack method, but I was hoping there would be something that was specific to ATLAS that would force the UpdatePanel to refresh.


hello again,

well, i guess that the answer is no, there isn't. and the reason is simple too: the update panel is just a delimiter that identifies a region which will be refreshed dinamically. all the partial postbacks are controlled by the pagerequestmanager object which uses the updatepanels defined on the page (normally divs or spans) to decide if it should perform a partial or a complete postback.


Ok, so what would you say would be the best way to accomplish this? It sounds as though the options are limited to the dummy button approach or explicitly calling __doPostBack.

hello again.

yep, that's it. i think that currently, there's no other option to perform that kind of operation.

Saturday, March 24, 2012

UpdatePanel + MultiView + TreeView do not work

HI

I have simple master page having the ContentPlaceHolder inside an UpdatePanel.

<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

My content page has a MultiView and Two View controls. Each View control has a TreeView inside. My problem is the TreeView in the first View can expand/collpase but the one in the second view has no response when clicking on it. What is going on?
<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TemplatedPage.aspx.cs" Inherits="TemplatedPage" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Button ID="Button1" runat="server" Text="Switch pane" OnClick="Button1_Click" /> <asp:MultiView ID="mv1" runat="server" ActiveViewIndex="0"> <asp:View ID="view1" runat="server"> <asp:TreeView ID="TreeView1" runat="server"> <Nodes> <asp:TreeNode Text="Tree 1" Value="Tree 1"> <asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView> </asp:View> <asp:View ID="view2" runat="server"> <asp:TreeView ID="TreeView2" runat="server"> <Nodes> <asp:TreeNode Text="Tree2" Value="Tree2"> <asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView> </asp:View> </asp:MultiView></asp:Content>

Code behind:

public partialclass TemplatedPage : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) {if (mv1.ActiveViewIndex == 0) mv1.ActiveViewIndex = 1;else mv1.ActiveViewIndex = 0; }}

From my limited knowledge treevie and menu controls are not currently supported in the ajax enviroment.. thus you will need to resort to a iframes approach or simply not place menu or treeview controls into a update panel. It is the Goal however of the Asp.Net to make all current .Net controls usable with the update panel but it won't most likely happend until the release of Orcas..

It is probably related to my problem with the Multiview control:

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

UpdatePanel and "foreign" characters

Hi!

I'm using an UpdatePanel with a DataList inside and a Trigger that updates the panel.

In Explorer no updates are shown if the datalist contains swedish characters ( ?, ? or ?), the trigger works but the "old" content is still shown. This works perfectly fine in FireFox.

Any suggestions?

/Jovan

I tried to simulate this and it appears to be working okay. What I did was have both FormView and DataList for a table within the same UpdatePanel. I've also handled the ItemUpdated event for the FormView and invoked DataList.DataBind() method to refresh the DataList content. Using your swedish characters for one of the FormView updates, it gets reflected to the DataList. I'm using IE version 6.0.

updatepanel and cyrillic encoding problem

Hi!

I'm facing the next problem now:

All cyryllic characters (my site has 'windows-1251' codepage) within textboxes, that are located in updatepanel control turn into abracadabra like this - "Р?Р'Р'Р"Р" when I press any button inside update panel, which cause asynchronous postback. I have obviously defined codepage in web.config

<

globalizationfileEncoding="windows-1251"requestEncoding="windows-1251"responseEncoding="windows-1251"culture="ru-RU"uiCulture="ru-RU"/>

and in every page

<metahttp-equiv="Content-Type"content="text/html; charset=windows-1251"/>

and have no idea where else do I need to define it in order to prevent such transformations !

Look at http://www.guysmithferrier.com/ and in particular at Guy Smith's bookISBN 0321341384 this book was approved by the Microsoft Globalisation Team

Also his presentation http://www.guysmithferrier.com/downloads/teni18n.pdf


Can you point me exactly on the article or another source on this site because I'm not shure what to search. I'd appreciate it very much. Don't you make me to search through entire site! -(
Regrettably my copy of Guy's book is locked in my desk drawer back at client site so I will not will able to look it up until late on Tuesday.

Ok, I could wait. Thanks.

Don't you know is there an electronic version of this book?


Look at http://safari.oreilly.com/0321341384 - it is available online at Safari Books
Thanks a lot! Anyway, I'm still waiting you to point a chapter which illustrates my problem solving...

See chapter 5 of Guy's book.

You may need to make up a minimal form demonstrating the problem and post that.


TATWORTH:

See chapter 5 of Guy's book.

You may need to make up a minimal form demonstrating the problem and post that.

I think a book won't help in this situation because it seems that we simply faced an updatepanel bug here.

There is a newer thread about this (Encoding Problem with Ajax), it has a small and simple example also to reproduce the bug(?)

UpdatePanel and Exceptions

Hi

I have an UpdatePanel using a trigger from the click event on a button. Everything seems to works ok, the click event hits the code-behind. My question is, how do you tell the page that an exception occured in the code-behind?

Many thanks

Craig

Hi,

you can use the ErrorTemplate provided by the ScriptManager control:

<ErrorTemplate>
<div>
There was an error processing your action. <br />
<span id="errorMessageLabel"></span>
<hr />
<button type="button" id="okButton">OK</button>
</div>
</ErrorTemplate>

This way, all the controls on the page will be disabled and the Exception message will be displayed in a nice overlay. You can customize the appearance of the ErrorTemplate but notice that the ids in red are "hard-coded-ids". The first is a label that displays the error message, the second is a button that re-enables the page.

Moreover, you can catch the PageError event of the ScriptManager control:

<atlas:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true"
OnPageError="ScriptManager1_PageError">

and, in codebehind, declare an event handler in which you can do custom processing of the error message:

protected void ScriptManager1_PageError(object sender, PageErrorEventArgs e)
{
e.ErrorMessage = "Unable to complete the request because: "
+ "<strong>"
+ e.Error.Message
+ "</strong>";
}

The PageErrorEventArgs instance exposes two properties:ErrorMessage that can be set to the error message that the client will receive;Error that returns a reference to the Exception instance.

Hi Garbin

My script manager is in a MasterPage:

<atlas:ScriptManagerID="scriptmanager"runat="Server"EnablePartialRendering="true"/>


How can I access the<ErrorTemplate> or the PageError event from the MasterPage in my aspx page which uses:

<atlas:ScriptManagerProxyID="scriptManager"runat="server"EnableScriptComponents="false">

I have a user control which renders a nice messagebox, so to be consistant I'd want to use that.

Thanks for your help.

Craig


Hi,

you cannot add an ErrorTemplate to the ScriptManagerProxy, but only to the ScriptManager control. But to preserve consistency it seems to me a good idea to have an ErrorTemplate in a MasterPage.

You can also drop in the ErrorTemplate a UserControl, just ensure that the ScriptManager is located inside the <form />. One problem however is that, as you know, the UserControl modifies the ClientID of its child controls and the ScriptManager relies on two hard-coded ids ("errorMessageLabel" and "okButton") to work as expected. One solution would be to assign these ids to non-server controls.