Showing posts with label panels. Show all posts
Showing posts with label panels. Show all posts

Wednesday, March 28, 2012

Programatically accessing Panels and Triggers (In CodeBehind at least)

I have a extensive toolkit that I have written over the past year or two that automatically generates all of my grids, dropdowns, "detail views" and other things. I wanted to start incorporating some snazzy ajax enabled inline calendars and stuff like that. However all of my code is buried deep within class files that generate the controls dynamically. A typical page that has a grid in it is simply a ASP:Placeholder tag, and a snip of codebehind saying what table the user wants to view, and the users group ID (around 3 lines of actual code).

I so to really AJAX enable this I would need a few things to work out, but I don't want to bore you all with those details. I would have tried to do it all of this in my class library already if I could, but when I instantiate a new Trigger, and type "t." to see what options I have, they are only the 4 options that I would have with an variable of type object (Equals, ToString, etc). I cannot even find the "EnablePartialRendering" flag that you need to setup on these panels on the updatepanel obj. Many of these controls have very few if any extra methods/properties/events different from the "System.Web.UI.Control" that they all inherit from.

Am I doing something wrong?

AB

hello.

is this an intellisense problem? if so, have you added the using directive to the source file?


I don't think that there is a problem with the intellisense, I mean, I have been coding for a few years now in .Net, using the intellisense to figure out how things work, without even really bothering with the documentation. It would seem that the Atlas is not to the point where it has the necessary XML markups to the source for the descriptions and what nots to kick in...

Basically, I am looking for examples, given an ASP.Net placeholder, to atlas enable it from the codebehind only, not from the designer... Make sense?

AB

hello again.

let me see if i got this correctly: you want to use the atlas server controls (ex.: UpdatePanel) from your source code files, right?

well, this should work, though i think that the intellisense info is not done yet (ie, you can see the methods/properties, but no info about them). so, your best option is to use .net reflector to see what it does (or, you can allways post your doubts here)


Yes, that is correct.

Have you seen any examples accessing the UpdatePanel from source code? The only examples I have found are in the ASPX Markup files, not the .ASPX.CS codebehind files...

The methods and properties I see are very limited, but as I see it, it would be done like:

Microsoft.Web.UI.ControlEventTrigger t = new Microsoft.Web.UI.ControlEventTrigger();
Microsoft.Web.UI.UpdatePanel up = new Microsoft.Web.UI.UpdatePanel();
up.Controls.Add(SomeLiteralControl);
t.ControlID(SomeButtonControl.ID);
t.EventName("Click");

Now, I can cause "SomeButtonControl" 's click event to change the Literals content and it will ajax that new content into the page?

AB
Ohh yeah, I also don't get the autocomplete for <atlas:UpdatePanel in my ASPX pages, any ideas on that?

AB

hello.

yep, adding triggers should be done like that ( though you still need to add the trigger to the collection maintained by the panel and this should be done until the init event of the page - btw, adding controls to the panel can't be done like that because you need a template).

what problems are you having with the updatepanel?


Hello,

I think I have the same problem. I thought I will start and try to change the example from

http://atlas.asp.net/docs/util/srcview.aspx?path=~/Server/samples/UpdatePanel.src

So the Panel2 is added to PlaceHolder on Page, but the panel doesn't update than.

Any ideas how it should be then, were to initiate the Panel.

For the moment my source code looks like that:

public

partialclassDefault6 : System.Web.UI.Page

{

privateUpdatePanel Panel2;protectedint PostBackCount

{

get

{

return (int)(ViewState["PostBackCount"] ?? 0);

}

set

{

ViewState[

"PostBackCount"] =value;

}

}

protectedoverridevoid OnInit(EventArgs e)

{

this.Init +=new System.EventHandler(this.Page_Init);this.Load +=new System.EventHandler(this.Page_Load);base.OnInit(e);

}

publicvoid Page_Init(Object sender,EventArgs e)

{

Panel2 =

newUpdatePanel();

Panel2.Mode =

UpdatePanelMode.Conditional;

Panel2.ID =

"UPForm";

Panel2.ContentTemplate =

newCTemplate(this);ControlEventTrigger pBtnClikEventTrigger =newControlEventTrigger();

pBtnClikEventTrigger.ControlID =

"Panel3bButton";

pBtnClikEventTrigger.EventName =

"Click";

Panel2.Triggers.Add(pBtnClikEventTrigger);

phPanel2.Controls.Add(Panel2);

}

protectedvoid Page_Load(object sender,EventArgs e)

{

if (IsPostBack)

{

PostBackCount++;

}

}

protectedvoid Panel3aButton_Click(object sender,EventArgs e)

{

Panel2.Update();

}

publicclassCTemplate :ITemplate

{

privateDefault6 m_pInnerControl;public CTemplate(Default6 pInnerControl)

{

m_pInnerControl = pInnerControl;

}

publicvoid InstantiateIn(System.Web.UI.Control container)

{

container.Controls.Add(

newLiteralControl(" [" + m_pInnerControl.PostBackCount +"] "));

}

}

}

thanks a lot in advance

Anna


hello again.

sorry, i didn't look with attention to your code. btw, don't add the panel like that...OnInit is called ot handle the init event, so just call method that adds the panel instead of creating a delegate...i see that you set the trigger to a panel3dbutton...where is this button placed? note that if's inside an user control, you can't do that because you need the full id of the control.


hi,

Thanks for sam clues.

But i noticed that the posted code

upadtes the panel. I changed the line

container.Controls.Add(newLiteralControl(" [" + m_pInnerControl.PostBackCount +" " +DateTime.Now +"] "));

And the date is changed every button click. Only the m_pInnerControl.PostBackCount is always zero.

Anna

Programatically Create Tab Container and Tab Panels

Hi,

How can I create a tab container and subsequent tab panels within it using C# in the code behind?

Any help would be much appreciated.

Hello,

You can you the PlaceHolder Control to add the TabContainer on the page, like so: make sure to add the reference at the top - using AjaxControlToolkit;

 TabContainer container =new TabContainer(); TabPanel panel1 =new TabPanel(); TabPanel panel2 =new TabPanel(); TextBox txtOne =new TextBox(); txtOne.ID ="txtOne"; txtOne.Text ="Example Text"; panel1.HeaderText ="This is Header 1 Text"; panel1.Controls.Add(txtOne); panel2.HeaderText =" This is Header 2 Text"; container.Tabs.Add(panel1); container.Tabs.Add(panel2); PlaceHolder1.Controls.Add(container);
 
Hope this helps. 

Yep that was perfect...thanks for this!

Programmatic refresh of a tab

I have been trawling the forums for a while and still have no solution to my problem. I have multiple tabs each contained within update panels. What i need is for a submit button in one tab to perform the partial update and then programatically update a second tab as well. Any ideas would be greatly appreciated.

ok i finally solved my own problem. I set the updatemode property of the updatepanel to "always". That means that even if another tab is doing an async callback the other tab is always refreshed

Hi i am looking for past one week for tabview form in asp.net 2.0 plz could you help me how to create. i have search i dont have server control in asp.net 2.0. i cant use in my company in AJAX. so, plz let me know as soon as possible.

Thanks

dilip


Hi i am looking for past one week for tabview form in asp.net 2.0 plz could you help me how to create. i have search i dont have server control in asp.net 2.0. i cant use in my company in AJAX. so, plz let me know as soon as possible.

Thanks

dilip


Set UpdateMode="Always" will slow down the page if you have a lots of data on it. If you have many tabs but only want to update one or two of them,why don't try something like:

protectedvoid GridView1_RowUpdated(object sender,GridViewUpdatedEventArgs e)

{

GridView1.DataBind();

GridView2.DataBind(); UpdatePanel2.Update();

}

Programmatically adding multi DragPanelExtenders?

Hi;

First of all what I need is to have more then one dragable panels inside my page. DragAndDrop em, record their locations to the DB

I'm using this script that I found in asp.net forum to find the location:

<scripttype="text/javascript">
Sys.Application.add_load(dragSetup);
function dragSetup() {
var dragPanel = $find('dragPanelBehavior1');
dragPanel.add_propertyChanged(locationUpdatedHandler);// the handler would get the name of the property from the event args and if it is 'location' then do the right thing.
returnfalse; }

function locationUpdatedHandler(sender, eventargs) {
if(eventargs.get_propertyName() =='location') {
var dragPanel = $find('dragPanelBehavior1');
var label = $get('dragPanelLocation');
var loc = dragPanel.get_location()
label.innerHTML = loc;}
}
</script>

However because of this script I have in the webusercontrol whenever I add my second webusercontrol it returns an error because they both aims the same panel's dragPanelBehavior1.

I couldn't solve this problem, any help would be preciated.

Again what I actually need is more then one dragable panels containig a webusercontrol and that I can find the location.

Thanks in advance

Hi Kaan,

First, DragPanelExtender's BehavirID should be uniquej though they are in different WebUserControls which are located in the same page.

Secondly, in your situation, I think you should remove out the Sys.Application.add_load(dragSetup) and its related functions from WebUserControls to the page.

To get or set the Panel's location , we can also use

//get

var el = $find('DragPanelBID').get_element();
var newLocation = $common.getLocation(el);

//set

var finalLocation = new Sys.UI.Point(x,y);
$find('DragPanelBID').set_location(finalLocation);

Hope this help.

Best regards,

Jonathan

Monday, March 26, 2012

Providing Scroll Bars to update panel

Hi,
I am using ajax for loading different user controls . I have two main problems
1. I have a main page where i have 4 update panels . the structure is like the the following( i removed the atributes for each elemnet like id , runat etc
<table>
<tr>
<td><updatepanel><contenttemplate><uc1:ststicbar><ontenttemplate></updatepanel><td>
<td><updatepanel><contenttemplate><uc1:dynbar><ontenttemplate></updatepanel><td>
</tr>
<tr>
<td colspan=2><updatepanel><contenttemplate>content here<ontenttemplate></updatepanel></td>
</tr>
<tr>
<td colspan=2><updatepanel><contenttemplate><uc1:statusbar><contenttemplate></updatepanel><td>

</tr>
</table>

where i have two user controls on top
and one at the bottom representing toobars and ststus bar(bottom)
in the middle update panel i am loading different user controls.
my problems are.

1. I need the keep the top toolbars and bottom status bar always visible
ie when i load a user control in the midddle update panel if its height is more there should be a scroll bar
I tried with adiv tag for the content but not worked properly i find update panels emit div tag in the client.
is there any way to provide scrolling for the update panel.ie the div tag which is get emitted for the update panel.

Thanks and Regards
Jereesh

All the Style Tag works also with the table tr and td tag

apply ur style to the Table like

<table id=tbl1 style="OVERFLOW:auto;WIDTH:200px;HEIGHT:230px;">

<tr><td></td></tr>

</table>

It will sork fine iam using it.

any proble get back to me.


Hey,

Just put the update panel for which you wanna have the scrollbars, inside a panel saypanel1.

Set the height and width of the panel and set the scrollbar property of the panel as you like.

publish ajax website

Hi,

I am beginner with Ajax and I have done an app using some update panels and triggers but before I upload the app to the server I wanted to know if I have to do something on the server so the app will run without any problem.


1. I am not using any ajax control, only updates panel.

2. Do have to configure something?

3. Can I just publish the site and then upload it?

Can any body explain me something about it or maybe give me an URL where i can found some info.

Thanks a lot.


Just install the asp.net ajax framework on you server then you're good to go.

Thanks for your answer.

But it is a remote server so I do not think I have permissions to install the ajax framework. Or I have to tell my provider that I want that framework?

Thanks again.


hmmm hosting provider? Ask them, ... to do install it ... if they don't then transfer somewhere else. .. i'm with GoDaddy, and they have it ... the price is cheap too. if you do go with GoDaddy, check around for promotion code. i have one ... let me know if you need it ... Cheer.

I just talked to my provider and they do not have the ajax framework and the person that I working for does not want to change the provider. I know, I had to ask this person about this before I started....... there′s no way to run an app which has ajax without the Ajax Framework? I am just using update panels and triggers and no ajax controls.

Thanks a lot.


You can try putting the DLLs in the bin folder like the old "Atlas", but then your folder has to have full permission. AND for sure your provider will not give it to you.

i did try putting all the DLLs in the bin folder on my hosting provider (godaddy) when they didn't have ajax install. the result was, it blows up on me. yellow page. 'sigh' ...

who is your provider?


my provider is 1&1......why do I need full permission to put some dll in my projects?

Look I have all the Data access and the business logic in different projects. That means that in the client side I use the dll from those projects.

Do I need also full permissions to use these dll's in my project?

Or do I have to upload those project to server too?

Tanks a lot.

Wednesday, March 21, 2012

Question on Panels

Hi,
I would like to achieve the look in my app like live.com and pageflakes.com. How can I have multiple panels side by side? Do I just place panels into one table? How do I get them side by side? Do I creat a table with multiple columns and rows and add panels into each sections? Please advice.

Thanks

View->Source and you'll see the HTML they use. Work through to see how it's done. Looks like they will have either a TABLE structure or DIV elements.
Got it! Thanks.