[CLOSED] ConfigOptions

  1. #1

    [CLOSED] ConfigOptions

    Hi,

    I create a server control with configoption. If i add the configoption from mark-up, i always able to read it from code behind whenever i want. The problem is when i add the configOption from a codebehind. It look like the addition of configOption from code behind is not appeded to the viewstate, so it can't be readed from the subsequent ajaxrequest. I would like to know how to add the configoption to the viewstate?

    Thank you
    Last edited by Daniil; Jun 12, 2012 at 4:32 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please demonstrate how you add a config option in markup and how in code behind.

    Did you not wrap setting up a config option in code behind in the following condition?
    if (!X.IsAjaxRequest)
  3. #3
    Hi,

    As requested by @daniil, posting a code sample demonstrating exactly what you would like to see happen would be helpful.

    That said, the use of ViewState really isn't required when using Ext.NET. You should be able to avoid using ViewState without much problem. In fact, in Ext.NET v2.x, by default ViewState has been completely removed from the Request/Response cycle. You can change this setting to enable ViewState, but by default it's not used.
    Geoffrey McGill
    Founder
  4. #4
    Hi,

    Im sorry it was not configOption but StateManagedCollections. I found the most similar case to my problem was Markers in GMapPanel UX. Here is the code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GMapSample._Default" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Register Assembly="Ext.Net.UX" Namespace="Ext.Net.UX" TagPrefix="ux" %>
     
    <!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 id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" ID="ScriptManager1" />
             
            
            <ext:ViewPort runat="server" ID="ViewPort1">
                <Content>
                    <ext:BorderLayout runat="server" ID="BL1">
                        <Center>
                            <ux:GMapPanel runat="server" ID="CenterMap" Title="GMap Panel" ZoomLevel="14" GMapType="Map">
                                <MapControls GHierarchicalMapTypeControl="true" GLargeMapControl="true" />
                                <MapConfiguration DoubleClickZoom="true" ContinuousZoom="true" GoogleBar="true" ScrollWheelZoom="true" /> 
                                <CenterMarker GeoCodeAddress="4 Yawkey Way, Boston, MA, 02215-3409, USA">
                                    <Options Title="Fenway Park" />
                                </CenterMarker>
                                <Markers>
                                    <ux:Marker Lat="42.339641" Lng="-71.094224">
                                        <Options Title="Boston Museum of Fine Arts" />
                                        <Listeners>
                                            <Click Handler="Ext.Msg.alert('Its fine', 'and its art.');" />
                                        </Listeners>
                                    </ux:Marker>
                                    <ux:Marker Lat="42.339419" Lng="-71.09077">
                                        <Options Title="Northeastern University" />
                                    </ux:Marker>
                                </Markers>
                                <Buttons>
                                    <ext:Button runat="server" ID="PanButton" Text="Fenway Park StreetView">
                                        <Listeners>
                                            <Click Handler="#{PanWin}.show();" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button runat="server" ID="MapButton" Text="Fenway Park Map Window">
                                         <Listeners>
                                            <Click Handler="#{MapWin}.show();" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button runat="server" ID="Test" Text="Test">
                                        <DirectEvents>
                                            <Click OnEvent="TestCount"></Click>
                                        </DirectEvents>
                                    </ext:Button>
                                </Buttons>
                            </ux:GMapPanel>
                        </Center>
                    </ext:BorderLayout>
                </Content>
            </ext:ViewPort>
        </form>
    </body>
    </html>
    and the code behind

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    Marker m = new Marker();
                    m.Lat = 10.1;
                    m.Lng = 10.2;
                    
                    CenterMap.Markers.Add(m);
                }
            }
    
    
            public void TestCount(object sender, DirectEventArgs e)
            {
                Int32 cnt = CenterMap.Markers.Count();
            }
    The testcount disregard the marker added from pageload, so it always return 2.

    Thank in advance
  5. #5
    So, I was right in my guess.

    Quote Originally Posted by Daniil View Post
    Did you not wrap setting up a config option in code behind in the following condition?
    if (!X.IsAjaxRequest)
    As you are wrap the code in that condition, it is not executed during DirectEvent and, respectively, the CenterMap knows nothing about the third marker.

    You should remove that "if" statement if you need to access the third marker during DirectEvent/DirectMethod.
  6. #6
    Hi,

    My intention is to have a button so user can add markers. Consider if i have the fourth button:

    <ext:Button runat="server" ID="Test2" Text="Test2">
                     <DirectEvents>
                              <Click OnEvent="TestAdd"></Click>
                      </DirectEvents>
    </ext:Button>
    and the method
    public void TestAdd(object sender, DirectEventArgs e)
    {
                Marker m = new Marker();
                m.Lat = 10.1;
                m.Lng = 10.2;
    
                CenterMap.Markers.Add(m);
    }
    and everytime user click the third button he know how many markers has been created. Is it possible?
  7. #7
    It is possible if only you will recreate it manually on each request. Neither Ext.NET or ASP.NET do not recreate it automatically.
  8. #8
    Quote Originally Posted by Daniil View Post
    It is possible if only you will recreate it manually on each request. Neither Ext.NET or ASP.NET do not recreate it automatically.
    Where is the right place to keep the previous markers so I always able to recreate it?
  9. #9
    Well, Session or some external store like database.

    I would investigate the following article.
    http://www.codeproject.com/Articles/...torage-Objects

    It can help to choose the best approach for your scenario.

Similar Threads

  1. [CLOSED] ConfigOptions, how to add custom option?
    By pil0t in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 16, 2010, 12:08 PM

Posting Permissions