Showing posts with label panel. Show all posts
Showing posts with label panel. Show all posts

Wednesday, March 28, 2012

How do I wire a javascript function to an update panel so it fires when the panel is updat

I have a list of location in an update panel and a virtual earth map w/ pushpin's representing each of the locations. My update panel works great for paging through the location list using some custom paging where a the panel updates when the paging buttons are clicked. What I'd like to be able to do though is wire up an event handler to the update panel so when it refreshes, my javascript function can make a page method call and get new set of pushpins to display on the virtual earth map.

a) How do I get a reference to the update panel in javascript?

b) What is the update panel event that I wire a call back method to?

Thanks!

Hi there, you can accomplish this by hooking up a client side event handler to the PageRequestManager pageLoading event. The event args will indicate the list of UpdatePanels that are getting refreshed, you can inspec the array and if the UpdatePanel that you are interested in is being refreshed call your function.

More info here:http://ajax.asp.net/docs/tutorials/usingMsAjaxLibrary/default.aspx

Thanks,
Federico


Federico,

Thanks for the reply. Because the ASP.NET forums are moderated, I literally just figured it out before receiveing your reply. The PageRequestManager in Beta 1 is awesome!

- James


Hi Frederico

Your link appears to be broken - do you happen to know a working link for this topic ?

Thanks,
Richard

How do I use javascript to force an UpDatePanel to Update

Hi, I am trying to find a simple way to force a specific update panel to refresh/update from a javascript function. The reason being that I am trying to build a simple calendar control, simular to that on the AJAX Control Toolbox site under PopUpControlhttp://atlas.asp.net/atlastoolkit/PopupControl/PopupControl.aspx, and I want the calendar to update if a date has been manually entered into the text box. I have found that you have to add an atrribute to the date input text box to invoke a call to a javascript function. (I am using the calendar control that I make inside of a gridview control which is enbeded inside of multiple levels of Update Panels and the TextBox.OnChange() event does not fire when inside of a gridview. So I added the following to the Page_Load event:TextBox.Attributes.Add("OnMouseLeave","javascriptFunction()") ) The problem that I am having is what to add to thejavascriptFunction()to force a specific UpDatePanel to refresh. I can get all of the panels to update using a "__doPostBack('DateControl$DateDisplay',''); "but there seems like that should be a simple way to force only one panel to update. I've tried to click on a hidden button using a javascript click() event, but I continuosly get the follwing javascript error: " Microsoft JScript runtime error: '_postbackSettings.async' is null or not an object " Is there a way to implement theUpdatePanel.Update() function directly from Javascript? Am I even going in the right direction? Could I call one of my code behind functions from javascript to perform the UpdatePanel.Update()?

So in simple terms, when building a control how can i update a specific UpdatePanel in the control through a javascript function?

Help Please!! Thanks!Big Smile

There is no direct support for updating just a single panel. You can mostly achieve it by setting all your panels to be Conditional and then calling Update on just the ones you want.

Thanks,

Eilon

How do I update text in a panel using ajax and a timer?

This is a pretty basic question, I just need to update a textbox every few minutes without using a postback. The text is pulled from a sql query. Is there a example for how to do this somewhere? (simialar to how gmail updates, etc...)

Take a look at this: http://encosia.com/index.php/2007/07/25/display-data-updates-in-real-time-with-ajax/

If you're only updating a simple text label, you could skip the UpdatePanel in my example andupdate that text on the client side, using a web method.

A combination of those two examples should give you what you're after.


Thanks for providing links.

How do I update a panel on page load?

I am sure it's something dumb.

Using the december preview. How do I update a panel on page load without a timer or a button? Obviously I want this done after the page loads and renders.

Thx
dB.

You can call the Update method on UpdatePanel.

HOW DO I update a control from outside the updatepanel

i have an update panel with 4 panels. when the user select panel 2 i need a control outside the updatepanel to become visible. i can not put the hidden div inside the updatepanel because the contents of the div will not work. how do update the div control from panel 2?

To make visible the control outside updatepanel is not possible upto my knowledge. definitely you have to include that control into another udpatepanel or include it with your 1st updatepanel.


Hi CurlyFro,

Here is the sample to indicate how to show a hidden div, which is out of a UpdatePanel, from a panel click event or a button click event in UpdatePanel. Hope it helps.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void Button2_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "showDiv();", true); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <script language="javascript"> function showDiv(){ document.all.myDiv1.style.display=''; //do something here to update the hidden div } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate><%=DateTime.Now.ToString()%> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="200px" onclick="showDiv()" BorderColor="AliceBlue" BorderWidth="1px"> <input id="Button1" type="button" value="button" /> </asp:Panel> <br/> <asp:Panel ID="Panel2" runat="server" Height="50px" Width="200px" BorderColor="Black" BorderWidth="1px" > <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="ServerSideButton" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <div id="myDiv1" style="width: 200px; height: 100px; display: none"> This is the hidden div </div> </form></body></html>

This sample contains two ways (server side and client side methods) to show the hidden div.

If i misunderstood you, please let me know!


i'm creating a registration form. panel1 is my license, panel2 is the registration form, panel3 is my confirmation. on panel2 i have form hints for specific textboxes. how do i get the form hints to be hidden then shown on panel2?

Since you have many steps, I suggesting to wrap these in an Asp.net Wizard Control then put the Wizard Control in an UpdatePanel.


Hi CurlyFro,

Would you please share your source code here ? It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Hi CurlyFro,

Has your problem been resolved yet?

How do I set off a process and display UpdatePanel on page load

I think this should be a simple task: I have a page that does some lengthy processing and I am using an update panel to show the user that something is happening. Currently, I have to load the page and the user has to press a buttong to start processing. Now, for me, this is a pointless step.. I want the page to kick off the server processing on page load and then display a page with the UpdatePanel which is then updated when the process is complete.

What is the best way to do this?.. Any suggestions?

:)

let me try this idea. once processing starts, you had the actual update panel, and show the update progress control, which gives the idea that processing is going on another page, then show the panel back again.

just a suggestion, since Atlas allows us to work with different parts of the page, somewhat like in windows forms.

a trial.

Regards,
formationusa


repost

Hide instead of had
sorry for the mistake, i have to check my spelling more often.

let me try this idea. once processing starts, you hide the actual update panel, and show the update progress control, which gives the idea that processing is going on another page, then show the panel back again.

just a suggestion, since Atlas allows us to work with different parts of the page, somewhat like in windows forms.

a trial.

Regards,
formationusa

How do I send email using ajax modal popup extender

I have a panel that sends an email message. I wish to use an ajax modal popup extender to display this panel when a user clicks a "Contact Us" link button. I get an error message when I try to run the application. My code follows.Thank you for any suggestions.

<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID ="ContactUsLinkButton"
PopupControlID ="EmailPopupPanel"
OkControlID="OKButton"
CancelControlID="CancelButton"
DropShadow="true"
BackgroundCssClass ="modalBackground" />
<asp:LinkButton ID="ContactUsLinkButton" runat="server">Contact Us</asp:LinkButton>


<div >
<asp:Panel ID="EmailPopupPanel" runat="server" CssClass ="popupEmail" Width="325px" Style="display: none" >
<asp:Label ID="TitleLabel" runat="server" BackColor="#FFFFC0"
Font-Bold="True" Font-Size="Medium" ForeColor="SteelBlue" Text="Contact D`Stroke Tennis"
Width="300px"></asp:Label>
<br />
<asp:Label ID="InfoLabel" runat="server" Font-Bold="True" Font-Size="Medium" ForeColor="Red"></asp:Label>
<br />
<br />
<asp:Button ID="OKButton" runat="server" BackColor="#FFFFC0" Font-Bold="True" ForeColor="DarkRed"
Text="OK" Visible="False" /><br />
<span style="color: #990000"><strong><asp:Label ID="FromLabel" runat="server" Text="From:"></asp:Label></strong> </span>
<asp:TextBox ID="FromTextBox" runat="server" Width="250px" ForeColor="DarkRed"></asp:TextBox>
<br />
<br />
<asp:Label ID="ToLabel" runat="server" Text="To: admin@dotnet.itags.org.dstroketennis.com" Width="300px" BackColor="#FFFFC0" Font-Bold="True" ForeColor="DarkRed"></asp:Label>
<br />
<br />
<span style="color: #990000"><strong><asp:Label ID="SubjectLabel" runat="server"
Text="Subject:"></asp:Label></strong></span>
<asp:TextBox ID="SubjectTextBox" runat="server" Width="240px"></asp:TextBox><br />
<br />
<span style="color: #990000"><strong>
<asp:Label ID="MessageLabel" runat="server"
Text="Message:"></asp:Label></strong></span><br />
<asp:TextBox ID="MessageTextBox" runat="server" Height="150px" TextMode="MultiLine"
Width="300px" ForeColor="DarkRed"></asp:TextBox><br />
<asp:Button ID="SendEmailButton" runat="server" BackColor="#FFFFC0" BorderColor="DarkRed"
BorderStyle="Solid" Font-Bold="True" ForeColor="DarkRed" Text="Send Email" Width="173px" />
<br />
<asp:Button ID="CancelButton" runat="server" BackColor="#FFFFC0" BorderColor="DarkRed"
BorderStyle="Solid" Font-Bold="True" ForeColor="SteelBlue" Text="Cancel Email" Width="173px" /></asp:Panel>
</div>
</form>
</body>

Tags:ajax, ie 7, Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null. Parameter name: element

When do you get the Sys.ArgumentNullException error? Also, try getting rid of the Style="display: none" on the Panel...

-Damien


I get the error when the page loads.


I Got rid of the Style "display : none" and I get the same error on page load.


See if this related post helps:http://forums.asp.net/p/1107533/1700376.aspx

-Damien


I also ran across this:http://www.spthorn.com/blog.php?post=28&PHPSESSID=c42ace58bb0f0d24ab3d9d2eef948c4a

-Damien


Thanks Damien. The asp buttons weren't plugged into anything I am guessing. My new challenge with this now is to have the email send, and display a message that the send was a success before leaving modal state.

At least this one issue is handled.

How do I play the animation on control B when hovering over control A?

Hello.

When I hover over a control (in my case a menu), and I want to play the animation on a panel instead my menu, how can I do that?

This is my code so far, I just can't figure out how to change from the menu to the panel.

<asp:scriptmanager ID="Scriptmanager1" runat="server" />
<asp:Menu ID="MyMenu" runat="server" .................................. /
<div class="AnimateThis" id="AnimateThis" runat="server">
This is the text I want to play the animation on.
</div
<ajaxToolkit:AnimationExtender ID="MyAnimation" runat="server" TargetControlID="MyMenu" BehaviorID="AnimateMyText">
<Animations>
<OnHoverOver>
<FadeOut/>
</OnHoverOver>
<OnHoverOut>
<FadeIn/>
</OnHoverOut>
</Animations>
</ajaxToolkit:AnimationExtender

Hi,

Take a look at the Animation Target section of theUsing Animations walkthrough.

Thanks,
Ted


It seems I should use AminationTarget to do this. Thanks.

Monday, March 26, 2012

How do I execute JS on page load after postback within an update panel?

I am trying to scroll the page after it loads between postbacks within an Update Panel. I used to have this work with beta 1

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<application load="onAutoScrollControlLoad" />
</components>
</page>
</script>

I am not sure how I came up with this, but it doesn't work with Beta 2 any more. Any ideas of how to implement the same functionality?

Thx
dB.

found a solution for this -http://forums.asp.net/thread/1418207.aspx

<scripttype="text/javascript">
function onAutoScrollControlLoad() { window.location.href ='#<% Response.Write(ScrollLocation); %>'; }
Sys.Application.add_load(function() { onAutoScrollControlLoad(); });
</script>

How do I collapse collapsible panels in UpdatePanel from code-behind?

Hi, all. There are quite a few posts about the collapsible panel here (some are my own), and I did a good amount of going through those, but they didn't seem to address my problem.

I have a master/detail setup in the form of a GridView in one collapsible panel and a FormView in another collapsible panel. The Grid- & FormViews work fine together. My problem lies in getting the collapsible panels to expand/collapse on a button clicked in the appropriate Grid/FormView. Actually, through much testing I found the problem lies in the fact that both the GridView and FormView are in their own UpdatePanels. When I comment those out, the code I have attached to the save button on the FormView does as it should: collapses the FormView panel and expands the GridView panel.

I tried using triggers for each of the UpdatePanels, setting the ControlID property to the FormView for the GridView's panel & vice versa for the FormView's panel. That didn't work...

Here's a code example to show you what I've got:

<asp:UpdatePanel ID="updPnlActCodeFmv" runat="server" UpdateMode="Conditional"><Triggers> <asp:AsyncPostBackTrigger ControlID="gvActCode" /></Triggers><ContentTemplate><asp:FormView ID="fmvActCode" runat="server" DefaultMode="Insert" DataSourceID="dsActCode"DataKeyNames="ActivityCodeID" BorderWidth="0px" Width="600px"> <InsertItemTemplate></InsertItemTemplate><EditItemTemplate> <asp:Button ID="btnSaveActCodeFmvChange" runat="server" CausesValidation="True" ValidationGroup="EditValidation"CommandName="Update" Text="Save Changes & Return to Table" Font-Bold="True" OnClick="btnSaveActCodeFmvChange_Click" /></EditItemTemplate></asp:FormView></ContentTemplate></asp:UpdatePanel><asp:UpdatePanel ID="updPnlActCodeGv" runat="server" UpdateMode="Conditional"><Triggers><asp:AsyncPostBackTrigger ControlID="fmvActCode" /></Triggers><ContentTemplate><asp:GridView ID="gvActCode" runat="server"> <Columns> </Columns></asp:GridView></ContentTemplate></asp:UpdatePanel>

Here's the code for the click event of the save button in the FormView:

Protected Sub btnSaveActCodeFmvChange_Click(ByVal senderAs Object,ByVal eAs EventArgs)
Dim cpeFmvAs AjaxControlToolkit.CollapsiblePanelExtender = cpeActCodeFmv
cpeFmv.Collapsed =True
cpeFmv.ClientState ="True"

Dim cpeGvAs AjaxControlToolkit.CollapsiblePanelExtender = cpeActCodeGv
cpeGv.Collapsed =False
cpeGv.ClientState ="False"

updPnlCpeActCode.Update()
End Sub

I'm not sure what else I can try - I need UpdatePanels around each of the View controls due to the amount of data being used in them, but with the UpdatePanels, I can't get the CollapsiblePanelExtenders to work they way I need them to!

Any help would be GREATLY appreciated!

Thanks

Anyone have any ideas on this?

Maybe my post was confusing.

In a nutshell, I need to expand & collapse Collapsible Panels via code-behind, while the controls (GridView & FormView) in each of the Collapsible Panels are all in Update Panels. The buttons the use clicks to do this are inside the Grid- & FormViews.

Using triggers doesn't work (at least the way I have them set up) and removing the UpdatePanels makes the collapse/expand code work.

HELP!


Man, Ihate talking to myself!

I was really hoping someone would post something over the weekend with some suggestion on how to deal with this!

Anyone?


Once again I would greatly appreciate it if someone could help me out on this. This is a feature I'm trying to implement on a site for a customer, so it is very important to me (and the customer) to be able to get this working!

PLEASE HELP!


[BUMP]

Eventually someone's GOT to have some clue!

Microsoft guys, where the heck are you?!?!??!


I suspect that is has to do with the conditional update. try always.

Not too sure how these things work with multiple update panels as it seems an event is being fired from one panel and you are trying to update another.


Hey, GSpies, thanks for the suggestion, but originally I didn't specify the UpdateMode and I found out that the UpdatePanles default to Always, which, in the case of my page, defeats the purpose of the UpdatePanels in the first place. As I mentioned in my original post, I have a lot of information being loaded on the page, so I need to control partial page postbacks based on certain events (GridView databinding, button clicks, dropdown selections, etc.). With the UpdateMode on Always, the UpdatePanel is, obviously, Always updated!

No, it's something else. I'm also dealing with trying to get a validation summary control and validatorcallout controls to work on the page within UpdatePanels and that endeavor isn't looking too good either.

Seems UpdatePanels, though very useful in and of themselves, really cause havoc with some other controls!


seeing as I am still stuck on the idea that it wont update if it is conditional, and the button you click is not one of the triggers, I wonder if using a behaviorid for the panel is appropriate and trying to fire that behavior from code-behind

Not having any direct experience in this problem, but sort of understanding how these things work, I would investigate.

Hope this helps


Hey, GSpies

Here's some info on UpdatePanels from the ASP.NET Documentation at:http://www.asp.net/AJAX/Documentation/Live/mref/P_System_Web_UI_UpdatePanel_UpdateMode.aspx

"The content of anUpdatePanel control is updated in the following circumstances:

If theUpdateMode property is set toAlways, theUpdatePanel control's content is updated on every postback that originates from anywhere on the page. This includes asynchronous postbacks from controls that are inside otherUpdatePanel controls and postbacks from controls that are not insideUpdatePanel controls.

If theUpdatePanel control is nested inside anotherUpdatePanel control and the parent update panel is updated.

If theUpdateMode property is set toConditional, and one of the following conditions occurs:

You call theUpdate() method of theUpdatePanel control explicitly.

The postback is caused by a control that is defined as a trigger by using theTriggers property of theUpdatePanel control. In this scenario, the control explicitly triggers an update of the panel content. The control can be either inside or outside theUpdatePanel control that defines the trigger.

TheChildrenAsTriggers property is set totrue and a child control of theUpdatePanel control causes a postback. A child control of a nestedUpdatePanel control does not cause an update to the outerUpdatePanel control unless it is explicitly defined as a trigger."


GOT IT!!

Okay, the gist of it was, I had to include the collapsiblepanel controlsinside an updatepanel as well, setting the ChildrenAsTriggers property as true, and then explicitly using the update method from the code-behind:

aspx example:

<ajaxToolkit:TabContainer ID="tabcont1" runat="server"><ajaxToolkit:TabPanel ID="tabPersonnel" runat="server"><ContentTemplate><br /><asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional"><ContentTemplate><ajaxToolkit:CollapsiblePanelExtender ID="cpe1" runat="server" /><asp:Panel ID="Panel1" runat="server"><asp:Label ID="Label1" runat="server" /></asp:Panel><asp:Panel ID="Panel2" runat="server"><asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel3" runat="server"><ProgressTemplate></ProgressTemplate></asp:UpdateProgress><asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:FormView ID="FormView1" runat="server"></asp:FormView></ContentTemplate></asp:UpdatePanel></asp:Panel><br /></ContentTemplate></asp:UpdatePanel><asp:UpdatePanel ID="UpdatePanel3" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional"><ContentTemplate><ajaxToolkit:CollapsiblePanelExtender ID="cpe2" runat="server" /><asp:Panel ID="Panel3" runat="server"><asp:Label ID="Label2" runat="server" /></asp:Panel><asp:Panel ID="Panel4" runat="server"><asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="UpdatePanel4" runat="server"><ProgressTemplate></ProgressTemplate></asp:UpdateProgress><asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="conditional" ChildrenAsTriggers="True"><ContentTemplate><asp:GridView ID="GridView1" runat="server"><Columns></Columns></asp:GridView></ContentTemplate></asp:UpdatePanel></asp:Panel></ContentTemplate></asp:UpdatePanel></ContentTemplate></ajaxToolkit:TabPanel></ajaxToolkit:TabContainer>

And in the code-behind:

Protected Sub btnSaveClose_collapseCpeFormView(ByVal senderAs Object,ByVal eAs EventArgs)Dim cpeFmvAs AjaxControlToolkit.CollapsiblePanelExtender = cpeFormViewcpeFmv.Collapsed =TruecpeFmv.ClientState ="True"Dim cpeGvAs AjaxControlToolkit.CollapsiblePanelExtender = cpeGridViewcpeGv.Collapsed =FalsecpeGv .ClientState ="False"updPnlPersGvOuter.Update()updPnlPersFmvOuter.Update()End SubProtected Sub btnEditMore_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Dim cpeFmvAs AjaxControlToolkit.CollapsiblePanelExtender = cpeFormViewcpeFmv .Collapsed =FalsecpeFmv .ClientState ="False"Dim cpeGvAs AjaxControlToolkit.CollapsiblePanelExtender = cpeGridViewcpeGv.Collapsed =TruecpeGv.ClientState ="True"updPnlPersGvOuter.Update()updPnlPersFmvOuter.Update()End Sub

In the GridView there is a button (btnEditMore) to click which populates the FormView with the selected record. That collapses the GV panel & expands the FV panel.

Conversely, when the "btnSaveClose" button is clicked in the FormView, the FV panel is collapsed and the GV panel is expanded.

Hope that info save someone else from the hassel I went through getting this to work!

How do I collapse Collapsible Panel

I'm trying to write SlideMenu very similar to the way that the SlideMenu onwww.obout.com works using the Atlas Collapsible panel extender.

Is there a way that I can programatically collapse the panel. basically if i have 5 panels controls collapsible if one if opened i want the other four to close. Can anyone tell me how i can do this in code behind or client side.

The newest release of the toolkit contains an Accordian control (sorry we don't have a sample page posted yet) that does exactly what you're looking for. Check it out by downloading from:

http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AtlasControlToolkit


Cheers, I realised I was being a bit of a muppet about 30 seconds after I posted this question.When I found the property sheet in intellisense. Unfortunately I didnt read your post until id finished writing my server control. But the Accordian was Exactly what I was looking for thanks. :-)

Now for my next task write and AVL Tree For the AutoCompleteExtender.

Saturday, March 24, 2012

How Do I add Atlas to a Current project?

All,I am trying to add atlas to a current project so I can use some things from the toolkit. I tried dragging in the collapsible panel from the toolbar, but what else should I do to make it work?

Karls

There is some stuff you have to add to your web.config. Search Google harder, it is out there, I just did this recently and had to find it. I believe it was on Scott's blog or the Microsoft web site. Don't get confused about how to add Atlas to Visual Studio (toolkit) from Adding Atlas to your project.

-Wayne

How do i access controls inside the update progress or update panel.

How do i access controls under the update progress or update panel.

I have 1 Update progress then i want to access the label inside the update progess. I want to change the text property of the label when my edit image button allter it. thanks

You will need to find the control recursively. However, the FindControl method will not find controls recursviely. Use this cool method FindControlRecursive(Control root, string id) by Jeff Atwood. The reason you cant access them otherwise is because they are child controls. Visit Jeff Atwoods article athttp://www.codinghorror.com/blog/archives/000307.html I use that to find controls. Once you find the control you will need to cast it to the type of control it is. Example:

TextBox tb = (TextBox)FindControlRecursive(Page,"txtNameOfControl");

tb.Text ="Hello there";

The above is an example as if you were finding a textbox.

Let me know if you need more help!

John


hello.

well, yes and no. for updatepanels, you don't need to use findcontrol since the controls are injected on the page as fields (which means you can simply use its id to get a reference to them)

regarding the updateprogress, things get a little messy. here's an example that shows how to change it during a full postback:

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
void E(Object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);
}

private Boolean update = false;

void J(Object sender, EventArgs e)
{
update = true;
}

protected override void Render(HtmlTextWriter writer)
{
if (update)
{
Label lbl = (Label) progress.FindControl("lbl");
lbl.Text = DateTime.Now.ToString();
}
base.Render(writer);
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" ID="panel">
<ContentTemplate>
<asp:Button runat="server" id="bt" text="partial postback" OnClick="E"/>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button runat="server" text="full postback" OnClick="J" />
<asp:UpdateProgress runat="server" ID="progress" AssociatedUpdatePanelID="panel">
<ProgressTemplate>
<asp:Label runat="server" id="lbl" />
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
</html>


Acutally I am trying to recall my orginal issue and why I used FindControlRecurvively and I beleive it was because I had a Drop Down List in a custom server control which was in an tab panel. The version of Ajax.net at the time had an issue with doing that and it throwing a null reference. This was some months ago so I don't recall all the logistics:

If you use FindControl to access a control inside a TabPanel, it throws a NullReferenceException.This behavior appears in the 10606 release10301. If you compile the same application with the March release (10301) it works well.
http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=11168


hello again.

ok, fair enough. but regarding the controls you've asked about (updatepanel and udpateprogress) my previous observations are correct.


Thanks for the reply, it works I've just create a new instance of label then assign the findcontrol to it.

dim lbl as label

lbl = updatepanel1.findcontrol("label1")

lbl.text = "hello"

thanks


hello again.

hum...why are you doing that? I mean, the controls declared inside an updatepanel are also inserted on the page as fields so you can only use its id to get them (this is not true for controls that are inside an updateprogress control)


Thanks for concern, I try it but it does not work, for example i have label1 inside the updatepanel1. So how do i access the label1 and change the text property?

Can you teach me how... Thanks again...


hello.

well, you just use its id:

label1.Text = "something";

do keep in mind that this code will only work if you're using it frmo the same page or user control that has the updatepanel which has the label inside...


Dim pwdAs ChangePassword

pwd = updatePanel1.FindControl("ChangePassword1")

pwd.Visible =True

This worked for me too, thanks guys.

Sasanka Pinidiya

How do I access controls in a TabContainer for FormView Select Parameters

I have a page with a gridview which is inside a tab panel.

Depending upon the selection in the GridView I need to set a Select Parameter for a FormView on another area of the page.

I simply get the error "Could not find control 'GridView2' in ControlParameter 'PoemID'"

Any suggestions ?

i got the same problem trying to access a label inside a tabcontainer...

someone pease help us!


I have had some success with resolving a similar problem by adding the name of the container to to the ControlId parameter as follows: ContainerName$Gridview2

I have an UpdatePanel with a textbox inside, further down the page I have a tab panel that needs to reference the value entered into the textbox and was able to get it to work by having the following syntax:<asp:ControlParameterControlID="UpdatePanel1$TextBox1" ...... what I can't work out is how to reference the same textbox from the tabpanel if it was placed within another tabpanel above or a different container such as an accordion panel. let me know if this gives you any clues...


Found any solution yet? I'm also facing the same problem. Thank you for sharing.

Men, thanks to you I could fix my application...

You just have to do the same with all the controls of the panel, but remember to use the tab container and the tab panel, OK... Here my example... Thnaks

--

SelectMethod="GetEmpleado_MByNumero"TypeName="RecursosHumanoBLL"UpdateMethod="UpdateEmpleadosMByNumeroEmpleado"OldValuesParameterFormatString="{0}">

<SelectParameters>

<asp:ControlParameterControlID="udpConsultaEmpleado$tcEmpleados$tpFiltro$gvEmpleados"DefaultValue="1"Name="Numero"

PropertyName="SelectedValue"Type="Int32"/>

</SelectParameters>

--

I hope it work for you too

How can we access a control outside the update panel with an control inside the update pan

Take a very simple example, i have a button inside the update panel along with other controls and i have a textbox on the page.What i want is that when i click the button inside the update panel,it should update the textbox which is present outside the update panel.How can i do this?

To my knowledge you cannot update any control outside of the update panel. If you want to update the control move it inside the update panel.

Do you want to modify the text box with server-side code? If so, put it in its own UpdatePanel. Set the UpdateMode on the panel to Conditional. Then you can either add the button in the other UpdatePanel as an AsyncPostBackTrigger to the new UpdatePanel or invoke the Update method on the new UpdatePanel in your button's Click event handler.

If you want to modify the text box on the client, you're going to have to write JavaScript.


Can you please tell me what javascript should i write for the sition i mentioned in the above example.

I am not getting the idea using javascript for a control inside the update panel.


Are you sure you need to write JavaScript? I gave you the steps to modify the text box using purely server-side code by using a second UpdatePanel control. I highly recommend you read theUpdatePanel tutorials and then re-read what I suggested. This path doesn't require JavaScript, but does require a round-trip to the server which is where your code will be executing.

If you do need to use JavaScript, you're going to need to handle the button's click event, modify the other control, and then prevent the default action for clicking the button from occurring (if necessary). This would all be done on the client so wouldn't require a round-trip to the server, but involves learning JavaScript and the DOM API (which you should want to learn as a web developer, anyways).


i have read it but still i feel i need javascript.Can u help me?

Wednesday, March 21, 2012

how can i use a textbox with an update panel during textchange

the case is, everytime the textbox will be change it will trigger a process wherin it will look for the data in the databse, after that it will display the data to a grid. the textbox & grid are place inside the update panel. It's just I only want that portion to be refreshed.

When an update panel posts the page back - your entire page is reloaded on the server. The client however only redraws the portions you've specified inside the update panel.

To accomplish this, and fire off the ontextchanged event you're looking for - set your textbox like this

<asp:textbox id="txtSearch" runat="server" autopostback="true" />

Now keep in mind, that this will only fire when the textbox looses focus.

how can i save panal places after drag and drop

i can use atlas's drag and drop options but i wanna save my panel's positions after drag and drop.

for example i have a 2 area . Left area and right area. and i have 3 draggableListItem.

after i changer draggableListItems's place i wanna write that changesin to xml file or somewhere whish is i can use later.?

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

how can i restate the focus inside updatepanel

hi,

i have several web controls inside a update panel. But i don't know how to set it so that right after my page come back from a callback, it will lost the focus. i tryed .focus() in asp.net, but it doesn't work... help anyone?

Alan,

after the focus method, try the upatepanel's Update() method.

it should work, although, i hide the same headache.

lblRowCount.Text = gridview1.Rows.Count.ToString();

txtProduitID.Focus();

pnlProduit.Update();

in this sample code, txtproduitID is the textbox where i type in the product code. and pnlProduit is the update panel.
this works for me.

regards,
formationusa


I tried that but it didnt work. Here is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void btn_Click(object sender, EventArgs e) { txt1.Text = DateTime.Now.ToString(); txt1.Focus(); up2.Update(); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="scriptmanager" EnablePartialRendering="true" runat="Server" /> <atlas:UpdatePanel runat="server" ID="up2" Mode="Conditional"> <ContentTemplate> <asp:TextBox runat="server" ID="txt1"></asp:TextBox> <asp:Button runat="server" ID="btn" Text="Button" OnClick="btn_Click" /> </ContentTemplate> </atlas:UpdatePanel> </form></body></html>

Can you tell me what im doing wrong?


your syntax is correct, it seems to be something which will need more time. i tested your sample, and got the same problem. Also, in the forms i worked on, I have different conditions for setting the focus on the textboxes.
I will keep checking on this problem in more detail.

if others experience the same, please post.

regards,
formationusa


I have the same problem, but I want to set the focus AFTER the UpdatePanel has returned because it is adding the field I want to focus. I've tried using a client-side timeout to wait for the UpdatePanel to finish, but the time would change from one browser/client to another.

Is there a way to tell an UpdatePanel to execute a client-side method after it has updated?


setting the focus in AJAX seems to be working with Fireworks and not IE, please will that be fixed for future releases as its very crucial to have working properly for data entry Web pages.
Sorry, I meant Firefox browser and not fireworks, my apology.

How can I make the collapsible panel extender NOT remember client state on post back?

I see one of the "features" of the collapsible panel extender is that it remembers it's client state after a post back, but I don't want that behavior after a successful post back. I have a form to fill out inside the collapsible panel and after post back, I want the panel to close as an indication that it was completed.

I've tried turning view state off on the collapsible panel and loading the change onPreRender and nothing seems to work. Is this possible?

Hi,

You can setMyExtender.EnableClientState = false; beforeOnInit (i.e. inOnPreInit) to disable ClientState. You could also leave ClientState enabled and manually close the panel when you want withMyExtender.Collapsed = true; MyExtender.ClientState = true.ToString();.

Thanks,
Ted