Showing posts with label atlas. Show all posts
Showing posts with label atlas. Show all posts

Wednesday, March 28, 2012

Dynamic Gridview

Hi!

I've got a quetion on dynamic gridview load. In my atlas website project i have a gridview that i want to load dynamically. That is, I don't want to load all the data in my datasource because the web page could charge slowly; so, i want to charge only part of the data as fast as possible then, load the other paghes when the user asks for it. How can I do it? Am I to write a C# class in order to manage the load?

Thanks

hi,

it depends on what level do u want to do this ,at what level is it loading slowly.....1)from the dataserver to the dataobject or 2)the control to the current instance of the page...?


it downloads slowly from the dataserver to the dataobject

where is your select query placed?may be in datasource...... place it in a stored procedure as stored procedures are precompiled..... & call the stored procedure....also set EnablePaging to true of the gridview.


My query select is placed in my datasource and my EnablePaging is set to true

Dynamic Control creation not persisting through PostBack

Hey guys,

I've done some searching on dynamic control creation in the forums, but none of them take me to an Atlas page. I'm trying to build a HR Notification form with some simple Atlas UpdatePanels. Basically, I want to dynamically add Labels and TextBoxes to this form. For instance, if you select 3 from the Number of Children DDL, I want 3 child forms to be created under it. I've been able to create the forms (at least theoretically, I just create "test" Labels right now). The problem I'm running into is being able to read from these dynamically created Controls.

When I submit the form as a regular PostBack, all of my created labels seem to be lost. I get null exceptions when I try to use FindControl. Here are some code snippets:

protected void ddlNumChildren_SelectedIndexChanged(object sender, EventArgs e) {int runNum = Convert.ToInt32(ddlNumChildren.SelectedValue.ToString());int count = 0;while (count < runNum) { Label text=new Label(); text.ID ="testLabel" + count; text.Text ="test"; phNumChildren.Controls.Add(text); count++; } }protected void btnSubmit_Click(object sender, EventArgs e) {int runNum = Convert.ToInt32(ddlNumChildren.SelectedValue.ToString());int count = 0;while (count < runNum) { Label lbltest = phNumChildren.FindControl("testLabel" + count)as Label; Response.Write(lbltest.Text); } }

I'm assuming I have to save this data before the postback, but I need a little help in how I can do this. Thanks for your time and any help you can provide.

The problem is that the controls do not exist when the page is recreated during postback. You have two options :
1) Recreate the page during the Init() event if you have atlas UpdatePanels or Page_Load() if not
2) try http://www.denisbauer.com/ASPNETControls.aspx
3) Write your own code to save all controls in ViewState and reload them during the Init() event

Dynamic Atlas page

I am making a completely dynamic web page. I want to use Atlas for UI handling.
This means that all atlas controls I create in codebehind (But sometimes a template would be useful, but only html template - atlas code should be generated dynamically). The main idea is that while you enter data, page updates itself and either edits data or changes whole behaviour. So I have some questions
1) Where can I see which classes create which elements in Script tag?
2) Is it possible at all to dynamically change behaviour - for example, to make the same html button call different actions or to completely change part of html (span element) and accordingly change atlas scripts?
3) how to dynamically add atlas controls from codebehind and avoid rendering visible control - make only atlas script?
4) how to make visible part of atlas control to appear somewhere else not after closing HTML tag?It shouldn't work that way, I think. Atlas is more client side then server framework..point is to make smart client webapplications which requests only actually needed data from server. You can create all controls from code, but on client side it will look same as if you create them much easier way in designer.
It's all my personal option

You didn't understand the problem - I want to put more action in client-side. For example, when filling out order form, I want to check data (and autofill some fields) without postback.
But the way I want to build UI is dynamic - I make product definition (what data are necessary for particular product) and screen definition (where these necessary data show up in UI). And then I have helper class that goes through those definitions and creates UI controls. Currently I can create native ASP.NET controls, but I would like to use ATLAS instead.
So the problem is that all examples of ATLAS scripts I have seen so far are statically typed in *.aspx page. But I want to create those scripts at runtime using Microsoft.Web.UI.* classes. But I cannot find all classes that correspond to examples in static scripts. For example, how can I programmatically create serviceMethod tag?
Not all client-side Atlas controls have a server-side version yet. Forexample, there is no serviceMethod Atlas server-control yet.
You would have to write them yourself, or wait until a new version ofAtlas is released which includes more server-controls for the Atlasclient-side controls.

Where can I get more info on how to create a class that creates ATLAS script? What should I inherit from, what methods need to be implemented, etc?

Monday, March 26, 2012

Duplicate Items in dropdownlist inside an Updatepanel

Hi,

I have been working with Atlas for the past couple of weeks and I have a very simple page with a dropdownlist box inside a updatepanel. I have a button that inserts a value in the back-end database and refresh the dropdownlist. This button is also a trigger for the updatepanel. This dropdownlist is bounded to an ObjectDataSource.

The problem is that on the first click, the values in the dropdownlist are duplicated with the original list and plus the new value. So I have the original list show up twice and the new value at the end. However, on the second click, the dropdownlist is updated correctly with only the new value being appended at the end. Doesn't anyone have the same problem?

ThanksSmile

<atlas:UpdatePanelID="UpdatePanelReason"runat="server"Mode="Conditional">

<ContentTemplate>

<asp:DropDownListID="drpReason"runat="server"AppendDataBoundItems="True"DataSourceID="ObjectDataSource1"DataTextField="ITEM_SUB_TYPE_NAME"DataValueField="PK_ITEM_SUB_TYPE_ID">

<asp:ListItemValue="0">Select Reason</asp:ListItem>

</asp:DropDownList>

</ContentTemplate>

<Triggers>

<atlas:ControlEventTriggerControlID="btnAddReason"EventName="Click"/>

</Triggers>

</atlas:UpdatePanel>

My post-back method to insert a new value in the dropdownlist.

ProtectedSub btnAddReason_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles btnAddReason.Click

IfMe.txtNewReason.Text <>String.EmptyThen

Dim lookupMgrAsNew LookupManager

lookupMgr.insertItemSubType(Me.txtNewReason.Text, Session("ItemType"))

Me.drpReason.DataBind()

EndIf

EndSub

Problem solved!! All I have to do is clear all the items in the dropdownlist before calling databinding.

:)

Saturday, March 24, 2012

DropDownList1.SelectedValue allways the same on postbacks

Hi,

I'm new to Atlas/Ajax, so please forgive if this is a simple question.

I'm trying to create a simple solution, where I databinds a DropDownList and when the SelectedValue changes, a GridView must reflect the new data.

My problem is, when making the Ajax callback, the DropDownList.SelectedValue is always the same no matter what item is selected ind the DropDownList. Somehow the server does not know the new value.

Here's my code...

<formid="form1"runat="server">
<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server"/>
<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"/>
<div>
<atlas:UpdatePanelID="aup"runat="server">
<ContentTemplate>
<asp:GridViewID="GridView1"runat="server"/>
</ContentTemplate>
<Triggers>
<atlas:ControlValueTriggerControlID="DropDownList1"PropertyName="SelectedValue"/>
</Triggers>
</atlas:UpdatePanel>
</div>
</form>

Here's my code behind...

Imports

System.Data

Partial

Class _Default
Inherits System.Web.UI.PageProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
Call GetDropDownItems()
EndSubProtectedSub DropDownList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChanged
Call GetData()
EndSubPrivateSub GetDropDownItems()
Dim dtAs DataTable = .. get my DropDownList items as datatable
Me.DropDownList1.DataSource = dt
Me.DropDownList1.DataTextField ="text"
Me.DropDownList1.DataValueField ="ID"
Me.DropDownList1.DataBind()
EndSubPrivateSub GetData()
Dim dtAs DataTable = ... get data depending on theDropDownList1.SelectedValue <-- this is always the same!!
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
EndSub

End

Class

Hope you can help me out here.

Thanks!

M O J O

Sorry ... I found out the problem.

I just had to do this instead...

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
If Not Page.IsPostBack Then
Call GetDropDownItems()
End If
EndSub

Thanks anyway!!!

M O J O


Hi: Mojo

I had same problem, thank you for the hint.

Do you think why it happened, why Postback is important. Although it works, but I need to know why?

Will be great that you can give my some idea.

Thanks.

James


The reason is,

Whenever a DropDownList is databound, the SelectedValue is always cleared out. To prevent the users selection from getting cleared out, you would only databind the DDL on the first hit to the page (when it's not a PostBack). Then on subsequent PostBacks, you would not databind your DDL. The ListItems in the DDL will get restored to the control from ViewState and the users selection (as read from the forms Post data) will get set on the DDL control.


thanks, mbanavige, now i c

James

DropDownList using Atlas version 1.1

How can i implement atlas on dropdownlist using .net version 1.1. C#

If you're looking for the atlas client control, it's now called Microsoft.Preview.UI.Selector and resides in the Microsoft AJAX CTP.

As far as running atlas with .net 1.1, I believe you will only be able to use the client script and not the server portion.

DropDownList problem with ATLAS

Excuse-me for my poor english.

This is my code:

<

atlas:ScriptManagerID="smImmobili"runat="server"EnablePartialRendering="true"/>

<

atlas:UpdatePanelID="upProvinciaZona"runat="server"EnableViewState="True"RenderMode="Inline">

<ContentTemplate>

<tableborder="0"cellpadding="0"cellspacing="4"style="width: 98%"><tr><tdstyle="width: 109px"><strong>

Regione

</strong></td><tdcolspan="3"><asp:DropDownListID="cmbRegioni"runat="server"Width="190px"AutoPostBack="True"OnSelectedIndexChanged="cmbRegioni_SelectedIndexChanged"CssClass="Testo"></asp:DropDownList></td>

</tr><tr><tdstyle="width: 109px; height: 19px;"><strong>

Provincia

</strong></td><tdcolspan="3"style="height: 19px"><asp:DropDownListID="cmbProvince"runat="server"Width="190px"AutoPostBack="True"OnSelectedIndexChanged="cmbProvince_SelectedIndexChanged"EnableTheming="True"CssClass="Testo"></asp:DropDownList><strong></strong></td></tr>

<%

if(_ViewZone){ %><tr><tdstyle="width: 109px; height: 19px"><strong>Zona</strong></td><tdcolspan="3"style="height: 19px"><asp:DropDownListID="cmbZone"runat="server"Width="190px"CssClass="Testo"></asp:DropDownList></td></tr>

<%} %>

<trbgcolor="#044da4"><tdcolspan="4"style="height: 15px"></td></tr></table></ContentTemplate></atlas:UpdatePanel>

This is a "CascadingDropDownList Style" page, obiouvsly not from Atlas Toolkit.

On SelectedIndexChange Event on first dropdown I execute server side code to Fill the second drop down:

protected

void cmbRegioni_SelectedIndexChanged(object sender,EventArgs e)

{

FillComboProvince(

int.Parse(cmbRegioni.SelectedValue));

_ViewZone =

clsProvince.getProvince(cmbProvince.SelectedValue).ViewZone;

}

FillComboProvince is a Method that fill my combo with some cities.

ex... cmbProvince.Items.add(...)...

With EnablePartialRendering="true" don't work! WHY?

Is it a bug?

hello.

can you give us more details about what's wrong? btw, if you can build a small page that reprocudes the problem and post it here, you'll have more options of getting an answer...

Wednesday, March 21, 2012

Dropdownlist

I have just started using Atlas and I am having a little trouble changing the text of a label when a font is selected from a drop down list. When the font-family name is selected the entire dropdown list is moved into the label. Here is my code

C# code

protected

void Page_Load(object sender,EventArgs e)

{

if (!Page.IsPostBack)

{

DisplayLabel.Style.Clear();FontFamilyDropDownList.DataSource = System.Drawing.FontFamily.Families;

FontFamilyDropDownList.DataBind();

FontFamilyDropDownList.Items.Insert(0,

"Default");

}

}

protectedvoid FontFamilyDropDownList_SelectedIndexChanged(object sender,EventArgs e)

{

DisplayLabel.Text = FontFamilyDropDownList.SelectedValue;

}

ASP Code

<asp:LabelID="DisplayLabel"runat="server"Text="Test Atlas Controls"></asp:Label>

<atlas:UpdatePanelID="FontNameUpdatePanel"Mode="Conditional"runat="server"><Triggers><atlas:ControlEventTriggerControlID="FontFamilyDropDownList"EventName="SelectedIndexChanged"/></Triggers><ContentTemplate>

<asp:DropDownListID="FontFamilyDropDownList"runat="server"DataTextField="Name"OnSelectedIndexChanged="FontFamilyDropDownList_SelectedIndexChanged"AutoPostBack="true"></asp:DropDownList>

</ContentTemplate></atlas:UpdatePanel>

Any suggestions would be great

Thanks

Mike

Figured it out, needed to place the label inside of the ContentTemplate and remove the DropDownList for it to work.