Showing posts with label latest. Show all posts
Showing posts with label latest. Show all posts

Wednesday, March 28, 2012

Accessing objects in an UpdatePanel

I'm trying to reference a textbox that is located in an updatepanel and was successfully doing so until I installed the latest version of the CTP (Sept 2006) and now I don't have programmatic access to the objects in the update panel...how can I get to this? Below is my same code that worked in the last version:

<divid="footer">
<atlas:UpdatePanelID="udpStatusBar"runat="server"Mode="Always">
<ContentTemplate>
<asp:TextBoxID="tbxStatusMessage"runat="server"Enabled="False"SkinID="StatusBar"Width="455px"></asp:TextBox>
<asp:TextBoxID="tbxStats"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
<asp:TextBoxID="tbxDate"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
</ContentTemplate>
</atlas:UpdatePanel>
</div>

ASPX.cs

privatevoid DisplayMessage(string s)
{
((TextBox)this.Parent.Page.Master.Controls[3].FindControl("tbxStatusMessage")).Text = s;
}

myost2921:

I'm trying to reference a textbox that is located in an updatepanel and was successfully doing so until I installed the latest version of the CTP (Sept 2006) and now I don't have programmatic access to the objects in the update panel...how can I get to this? Below is my same code that worked in the last version:

<divid="footer">
<atlas:UpdatePanelID="udpStatusBar"runat="server"Mode="Always">
<ContentTemplate>
<asp:TextBoxID="tbxStatusMessage"runat="server"Enabled="False"SkinID="StatusBar"Width="455px"></asp:TextBox>
<asp:TextBoxID="tbxStats"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
<asp:TextBoxID="tbxDate"runat="server"Enabled="False"SkinID="StatusBar"></asp:TextBox>
</ContentTemplate>
</atlas:UpdatePanel>
</div>

ASPX.cs

privatevoid DisplayMessage(string s)
{
((TextBox)this.Parent.Page.Master.Controls[3].FindControl("tbxStatusMessage")).Text = s;
}

You should be able to access the control directly. This should work for your DisplayMessage function:

tbxStatusMessage.Text = s;

The problem is that my DisplayMessage is sitting in a UserControl that is loaded dynamically into the page. The UserControl knows nothing of the page until runtime.
The problem is that the DisplayMessage method is found in a UserControl which is being dynamically added to the page at runtime. I'm having to use the FindControl command because of that reason. Any more ideas?

What error are you getting? Have you tried just calling page.findcontrol()?

A quick example:

.aspx file:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="wizard_validation.aspx.vb" Inherits="wizard_validation" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="act" %><!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> <atlas:ScriptManager runat="server" ID="blah2" EnablePartialRendering="true"></atlas:ScriptManager> <atlas:UpdatePanel runat="server" ID="blah" Mode="conditional"> <ContentTemplate> <asp:Wizard ID="NewFormWizard" runat="server" Width="100%" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" CancelButtonText="Cancel" DisplayCancelButton="true" > <WizardSteps> <asp:TemplatedWizardStep ID="WizardStepGeneral" runat="server" Title="*General"> <ContentTemplate> <h1>Header!</h1> </ContentTemplate> </asp:TemplatedWizardStep> </WizardSteps> </asp:Wizard> </ContentTemplate> </atlas:UpdatePanel> </div> </form></body></html>

Code-behind (in VB, but I'm sure you can figure it out):

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadDim iAs Integer Dim tmpwizardAs Wizard tmpwizard = Page.FindControl("NewFormWizard")If tmpwizardIs Nothing Then' failure i = 0Else' success i = 1End If End Sub

It returns with a success on that sample page. However, this is not a dynamically added control, so if you could post an example if using "Page.FindControl" doesn't work, it'd be easier to help ya out.


I figured out the problem...turns out it was actually simplified even more in this release and the cause of the error was something completely different. Thanks Matt!

Monday, March 26, 2012

Accessibility and the UpdatePanel

Hi,

What's the latest info on accessibility and the UpdatePanel. Can screen readers handle async updates using the UpdatePanel?

Many thanks

Mat

Hi Matg,

Yes. Here the is the tutorials about Update. Hope it helps.

http://ajax.asp.net/docs/tutorials/UpdatePanelTutorials.aspx

If any problems ,please let me know!

Saturday, March 24, 2012

ABCs of compiling the AtlasControlToolkit source

Hello,

I was able to successfully change a few small items in the July CTP, build and use the binaries in a web solution. Very nice!

But the latest Sept. AtlasToolKit has me stumped. First of all, there is one less DLL (microsoft.AtlasControlExtender.dll) after I build and I wonder how this effects my old code. Also, when I remove the reference to the old DLL in VS an unknown process retains a lock on some files from the old referenced Atlas.

After I build the AtlastToolKit solution and add a reference to the TWO generated DLL's in VS everything looks fine within VS, no errors or missing references there. But when I run the code the Atlas portion simply does not work giving a simple JavaScript error "object does not exist"

So, my question is: Is there an FAQ or basic run down of how to transition from one version of Atlas to another...especially if we have modified some of the older versions scripts and code?

Hi,

all the code in Microsoft.AtlasControlExtender was moved into the AtlasControlToolkit namespace (this means that the source is now public), thus a required step is to replace all the references to Microsoft.AtlasControlExtender into references to AtlasControlToolkit. This has to be applied also in the JavaScript behaviors (look at the registerClass() function at the end of the file) that must inherit from AtlasControlToolkit.BehaviorBase.


Great, that helps a bunch.

Another question then, if I wanted to compile the source and NOT have the JS files as an embedded resource but instead use something like the SCRIPTPATH= , how do I build the AtlasControlToolkit? Ideally, this would also allow me to have a directory of JS files to debug against as well.

thanks!


Hi,

I don't know if it is possible to compile the Control Toolkit to reference external files. What you can do is reference an external JavaScript file when declaring an extender, via the ScriptPath property of the extender control.

Wednesday, March 21, 2012

A 101 question

I'm new to the MS Ajax library. I'm developing a .NET 2.0 website. I want to be sure I'm using the latest verion of the MS Ajax library and tool kit. Should I use v1.0 of both the library and toolkit or version 3.5 of each?

Thank you.

hello

you just need to have V1.0

in the future , if there is a new version,you need to replace the Dlls.

also there is no 3.5 version, if you mean the .Net 3.5 , then yes it contains the same Ajax version (1.0) !!


Thank you for the clarification.