Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Wednesday, March 28, 2012

Treeview + Update Panel

Hi!

I'm working on atlas and I'm testing some functionnality. I created a page with a treeview contained in an update panel and another update panel that shoul be updated when one selects a node but it doesn't work. Can someone help me?
Here is th source code:

<%@dotnet.itags.org. Page Language="C#" %>"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> void dataBound(Object sender, TreeNodeEventArgs e) {// Determine the depth of a node as it is bound to data. // If the depth is 1, show a check box. if (e.Node.Depth == 2) { e.Node.ShowCheckBox = true; } else { e.Node.ShowCheckBox = false; } } protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) {//If a node is selected, display the text in the right table Message.Text = TreeView1.SelectedNode.Text; }</script><html xmlns="http://www.w3.org/1999/xhtml" >First TreeView with an XML File"server"> "text/css"> div.global { width:100%; margin:0px; border:1px solid #99ccff; line-height:150%; } div.header,div.footer { padding:0.5em; color:white; background-color:#99ccff; clear:left; } div.left {float:left; width:200px; margin:0; padding:1em; } div.right { margin-left:270px; border-left:1px solid #99ccff; padding:1em; } "form1" runat="server"> true ID=ScriptManager runat=server/>

class=global>

class="header">Dynamic Atlas Tree View

class=left> "TreeView1" runat="server" DataSourceID="XDS" OnTreeNodeDataBound="dataBound" ShowCheckBoxes=None OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" ShowLines=true> "Kpf" ValueField="ID" TextField="Name"/> "Activity" ValueField="Value" TextField="Value"/> "XDS" runat="server" DataFile="~/XMLTVDataSource.xml">

class=right> Selected elements



"TreeView1" EventName="SelectedNodeChanged "/>

class=footer>KPF Nord

There is a bug with the TreeView. If you remove ShowLines (or set it to false) it should work. When ShowLines is set to true, the controlsometimes generates invalid xhtml.

For more details, check out this post:
http://forums.asp.net/forums/1196633/ShowPost.aspx


Thanks for your reply. This is the error generated when I debug:
"The EventName must be set to a valid event name on the associated control"
And it occurs because of the triggers tag.
Could someone help me to fix this problem?

Treeview Control How can I trap a callback function

In my web application I have an Ajax Treeview control which populates its child nodes via AJAX, and all is working beautifully except that all our pages turn on a "spinny" image whenever there is a postback either full or partial my problem is how can I trap the completion of the ajax postback so I can turn the spinny off?

I cannot find a treeview event that I can trap on the client side to do this.

I expect someone has ran into this issue before so any help would be gratly appriciated.

I have only recently started using AJAX and so far everything I have seen has been really good but I would to solve this issue.

Cheers

John

How are you populating the tree? What "Ajax Treeview control" are you using?

You should be able to attach a callback handler that will let you get rid of the "spinny", but without knowing your approach I can't recommend how to do this in your instance.

-Damien


Hi Damien

Here is the markup for the treeview I have removed the styling for berevity

<asp:TreeViewID="tvwProcess"runat="server"EnableClientScript="true"OnTreeNodePopulate="GetChildren"PopulateNodesFromClient="true"Style="overflow: auto; height: 490px">

</asp:TreeView>

GetChildren is a serverside method which populates the expanded node

Does this give you enough info?

Thanks

John


You should be able to use the ClientScript.GetCallbackEventReference to get a reference to the callback and then hide the image using the callback method (seehttp://west-wind.com/weblog/posts/2302.aspx for an example).

Hope this helps...

-Damien


Hi Damien

re:

You should be able to use the ClientScript.GetCallbackEventReference to get a reference to the callback and then hide the image using the callback method (seehttp://west-wind.com/weblog/posts/2302.aspx for an example).

I tried your suggestion and got the example from west-wind working fine and also this example from Microsoft http://msdn2.microsoft.com/en-us/library/ms153106.aspx

the problem I still have with the treeview is what event to attach it to. The logical option would be the "OnTreeNodeExpanded" but that looks for a server side methodAm I missing something?CheersJohn

Hi,

At the client side,the"OnTreeNodeExpanded" is the click event of the parent Node.

TreeView in UpdatePanel : Heres a working one

Okay, I've seen this mentioned a bunch of times, people can't get TreeView's working in an update panel. Well I've never had a problem. What I figured out was I used a different methodology to fill my tree. Instead of using the "TreeNodeExpanded" event I use the "TreeNodePopulate" event, and set any node that has children's "PopulateOnDemand" property to true. Here's a full solution that uses your file system as an example (since everyone has one) that works for me (running as a file system site at least since I have admin privie's to my drive.)


Either way it demonstrates the concept, and a working solution that uses a TreeView inside of an UpdatePanel. Hopefully this is helpful. If I'm way off base and this isn't REALLY working let me know, but I have a rather complex dynamically loaded treeview solution that works in a production app, and as far as I can tell it is completly populated server side via ajax postbacks.

<%

@dotnet.itags.org.PageLanguage="C#" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions"Namespace="System.Web.UI"TagPrefix="asp" %>

<%

@dotnet.itags.org.ImportNamespace="System.IO" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

scriptrunat="server">

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!Page.IsPostBack)

{

BuildTree();

}

}

protectedvoid BuildTree()

{

tvFiles.Nodes.Clear();

TreeNode root =newTreeNode("Drives",@dotnet.itags.org."0");

root.SelectAction =

TreeNodeSelectAction.None;

root.PopulateOnDemand =

true;

root.Selected =

false;

tvFiles.Nodes.Add(root);

tvFiles.ExpandDepth = 1;

root.Expand();

}

protectedvoid tvFiles_TreeNodePopulate(object sender,TreeNodeEventArgs e)

{

TreeNode parentNode = e.Node;if (parentNode.Value ==@dotnet.itags.org."0")

{

PopulateDrives(parentNode);

}

else

{

PopulateNormal(parentNode);

}

}

protectedvoid PopulateDrives(TreeNode node)

{

string[] drives =Environment.GetLogicalDrives();foreach (string drivein drives)

{

TreeNode driveNode =newTreeNode(drive, drive);

driveNode.SelectAction =

TreeNodeSelectAction.None;

driveNode.Selected =

false;

driveNode.PopulateOnDemand =

true;

node.ChildNodes.Add(driveNode);

}

}

protectedvoid PopulateNormal(TreeNode node)

{

string path = node.Value;try

{

DirectoryInfo directory =newDirectoryInfo(path);foreach (FileSystemInfo childin directory.GetFileSystemInfos())

{

TreeNode childNode =newTreeNode();

childNode.Text = child.Name;

childNode.Value = child.FullName;

if (childisDirectoryInfo)

{

if (((DirectoryInfo)child).GetFileSystemInfos().Length > 0)

{

childNode.PopulateOnDemand =

true;

}

}

node.ChildNodes.Add(childNode);

}

}

catch

{

//HACK: ignore erros, probably security, just don't add the nodes

}

}

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><div><asp:ScriptManagerrunat="server"id="scriptManager1"></asp:ScriptManager><asp:UpdatePanelrunat="server"id="treePanel"><ContentTemplate><asp:TreeViewID="tvFiles"runat="server"OnTreeNodePopulate="tvFiles_TreeNodePopulate"></asp:TreeView></ContentTemplate></asp:UpdatePanel>

</div></form>

</

body>

</

html>Nice one.

This is excellent, I was close to dropping the TreeView and rolling my own.

However I now have the problem of persisting the TreeView state accross postbacks. The nodes are being populated from a database through the NodePopulated event. Previously we had a function in NodeExpanded and NodeCollapsed that saved the state to a session variable. Any ideas on the best way to do this now?


On closer inspection this doesn't work as expected. It doesn't appear to make use of the UpdatePanel at all, its just using its PopulateOnDemand feature that was always there. When I have another UpdatePanel on the page and cause a postback inside that, the next attempt to expand a node throws back an error:

Invalid postback or callback argument. Event validation is enabledusing <pages enableEventValidation="true"/> in configuration or<%@. Page EnableEventValidation="true" %> in a page. For securitypurposes, this feature verifies that arguments to postback or callbackevents originate from the server control that originally rendered them.If the data is valid and expected, use theClientScriptManager.RegisterForEventValidation method in order toregister the postback or callback data for validation.

Heres the changed code:

<%@. Page Language="C#" %><%@. Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %><%@. Import Namespace="System.IO" %><!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) { if (!Page.IsPostBack) { BuildTree(); } } protected void BuildTree() { tvFiles.Nodes.Clear(); TreeNode root = new TreeNode("Drives", @."0"); root.SelectAction = TreeNodeSelectAction.None; root.PopulateOnDemand = true; root.Selected = false; tvFiles.Nodes.Add(root); tvFiles.ExpandDepth = 1; root.Expand(); } protected void tvFiles_TreeNodePopulate(object sender, TreeNodeEventArgs e) { TreeNode parentNode = e.Node; if (parentNode.Value == @."0") { PopulateDrives(parentNode); } else { PopulateNormal(parentNode); } } protected void PopulateDrives(TreeNode node) { string[] drives = Environment.GetLogicalDrives(); foreach (string drive in drives) { TreeNode driveNode = new TreeNode(drive, drive); driveNode.SelectAction = TreeNodeSelectAction.None; driveNode.Selected = false; driveNode.PopulateOnDemand = true; node.ChildNodes.Add(driveNode); } } protected void PopulateNormal(TreeNode node) { string path = node.Value; try { DirectoryInfo directory = new DirectoryInfo(path); foreach (FileSystemInfo child in directory.GetFileSystemInfos()) { TreeNode childNode = new TreeNode(); childNode.Text = child.Name; childNode.Value = child.FullName; if (child is DirectoryInfo) { if (((DirectoryInfo)child).GetFileSystemInfos().Length > 0) { childNode.PopulateOnDemand = true; } } node.ChildNodes.Add(childNode); } } catch { //HACK: ignore erros, probably security, just don't add the nodes } }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>Untitled Page</title></head><body><form id="form1" runat="server"><div><asp:ScriptManager runat="server" id="scriptManager1"></asp:ScriptManager><asp:UpdateProgress ID="prog" runat="server"> <ProgressTemplate>Working...</ProgressTemplate></asp:UpdateProgress><asp:UpdatePanel runat="server" id="treePanel" UpdateMode="conditional"><ContentTemplate><asp:TreeView ID="tvFiles" runat="server" OnTreeNodePopulate="tvFiles_TreeNodePopulate"></asp:TreeView><input type="submit" id="btn1" runat="server" value="same panel" /></ContentTemplate></asp:UpdatePanel> <asp:UpdatePanel ID="upd1" runat="server" UpdateMode="conditional"> <ContentTemplate> <input type="submit" id="btn2" runat="server" value="other panel" /> </ContentTemplate> </asp:UpdatePanel> </div></form></body></html>

Thanks badgrs. My current project has the treeview alwaysbeing re-initialized on any updatepanel postback. That is quiteunfortunate. I will need to evaluate wether to use theUpdatePanel now. I may end up doing a part UpdatePanel part"manual" solution where the items that are selected in the TreeView donot use UpdatePanel tech, but custom web service call-backs.

Thanks for the input.

Monday, March 26, 2012

Treeview is slow to respond when a node is selected

I am working on an application that is using the TreeView.

Theway it's functions is the tree displays all the available families offunds. When the node is expanded, it shows the funds for thatparticular family (PopulateOnDemand is set to true). When the fund isclicked, it's added to a checkbox list. It's working, but when the fundis getting added to the checkbox list it's very, very slow. I'd like to get rid of the lag, because it's pretty unusable at this state

I am posing my code, and i hope someone can help me

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Copy of Default.aspx.cs"
Inherits="_Default" %
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="Local_Resources/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<table>
<tr>
<td valign="top">
<cc1:TabContainer ID="TabContainer1" runat="server" Width="460px" Height="400px" ScrollBars="Auto">
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Browse Funds">
<ContentTemplate>
<asp:UpdatePanel runat="server" UpdateMode="conditional" ID="tvUpdatePanel">
<ContentTemplate>
<asp:TreeView ID="TreeView1" OnTreeNodePopulate="PopulateNode" OnSelectedNodeChanged="SelectNode" ExpandDepth="0" runat="server">
<Nodes>
<asp:TreeNode Text="root" SelectAction="Expand" PopulateOnDemand="true" />
</Nodes>
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</td>
<td valign="top">
<asp:UpdatePanel runat="server" ID="upResult" UpdateMode="Always">
<ContentTemplate>
<div class="checkboxListWrapper">
<asp:CheckBoxList ID="cblResults" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partialclass _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}

protected void PopulateNode(object source, TreeNodeEventArgs e)
{
switch (e.Node.Depth)
{
case 0:
GetFundFamilies(e.Node);
break;
case 1:
GetFundsByFamily(e.Node);
break;
}
}
protected void GetFundFamilies(TreeNode node)
{
foreach (DataRow drin DAL.getAllFundFamilies().Tables[0].Rows)
{
TreeNode tempNode =new TreeNode(dr[1].ToString(), dr[0].ToString());
tempNode.SelectAction = TreeNodeSelectAction.Expand;
tempNode.PopulateOnDemand =true;
node.ChildNodes.Add(tempNode);
}
}
protected void GetFundsByFamily(TreeNode node)
{
foreach (DataRow drin DAL.getFundsByFamily(node.Value.ToString()).Tables[0].Rows)
{
TreeNode tempNode =new TreeNode(dr[1].ToString(), dr[0].ToString());
node.ChildNodes.Add(tempNode);
}
}
protected void SelectNode(object sender, EventArgs e)
{
TreeView tv = (TreeView)sender;
ListItem li =new ListItem(tv.SelectedNode.Text, tv.SelectedNode.Value);
cblResults.Items.Add(li);

}

}

TreeViews are supported in update panels. You can kind of use them, BUT you will get errors if you try to change a treeview after the initial pageload. If it doesn't change, you should be able to use a treeview inside an update panel without errors. Menus and report viewers are also not supported.

Well, that doesn't answer my question. My tree works just fine. It's just very slow.

When doing some testing i found that when i click on a node, it looks like the entire tree reloads. I don't think i have that problem when i am not using the UpdatePanel, but that defeats the purpose.


Well, that doesn't answer my question. My tree works just fine. It's just very slow.

When doing some testing i found that when i click on a node, it looks like the entire tree reloads. I don't think i have that problem when i am not using the UpdatePanel, but that defeats the purpose.


My point was that you CAN'T get Ajax functionality with the built in Treeview. If you want that, you need a 3rd party control.

in that case i am confused

if it would work, it would just not work. My problem is that it IS working. I just need it to be faster.

I am guessing you mean it doesn't support asynchronous postback? But i can the child nodes to populate on demand without a page reload. If i can't get the tree to work, i can just adapt a GridView for my purposes, or just write a custom control. I don't need too much functionality.


You would probably want to adapt the gridview then. Since the Beta releases, treeviews haven't worked well, if at all when you try to do anything dynamic with them after the initial page load. Before the betas, there was a way to do this, but there were big changes that changed that. We spent a lot of time trying to get it to load dynamically when we were switching our site from the July CTP to releases after that.

that's what i am trying to do right now actually

even with a gridview it's tricky and i ran into the same problem of the whole grid expanding when a node is clicked

i guess i need to add multiple update panels to make it work

Treeview not working in Beta 1.0?

I have a treeview that used to work in CTP July version but stopped working after I installed the beta version.

The first problem: say I have node A and it has at least one child. If I expand node A (by clicking the + button) then click on the name of the node, it readds the children, effectively doubling the number of the nodes. I could continue adding the children of the nodes resulting is multiple children being added.

The second problem relates to the first one. Expand node A, expand node B, select node B then select one of node B's child. Somehow one of node A's child is expanded.

The third one: I can't expand more than two levels. Everytime I try to do it, this error message appears:

Line: 82
Error: 'undefined' is null or not an object

Looking at source, the line that breaks it is this:

table.insertAdjacentHTML("afterEnd", chunk);

All of the nodes have PopulateOnDemand = true. Am I doing something totally wrong or is it really a bug in the beta 1.0? Every other controls (including the ones from value pack) seems to work properly except this treeview. :(

For reference here's what I have on the aspx page:

<div class="BrowserTreeView">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="tvDirectory" runat="server" OnTreeNodePopulate="PopulateNode" OnPreRender="tvDirectory_PreRender" OnSelectedNodeChanged="tvDirectory_SelectedNodeChanged" SkinID="Explorer"></asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostbackTrigger ControlID="cmbComputer" EventName="SelectedIndexChanged"></asp:AsyncPostbackTrigger>
<asp:AsyncPostbackTrigger ControlID="cmdOpen" EventName="Click"></asp:AsyncPostbackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>

Please see these two articles:

- What's up with UpdatePanels and how come nothing works? (http://forums.asp.net/thread/1440058.aspx)
This is a higher level piece that explains how UpdatePanel changed from being automatic (and broken) in the CTP to the new functionality in the beta.

- HOWTO: Write controls compatible with UpdatePanel without linking to the ASP.NET AJAX DLL (http://forums.asp.net/thread/1445844.aspx)
This article goes in depth on how to use the new registration APIs on ScriptManager, but without linking to the Atlas assembly.

Thanks,

Eilon


Thanks. I didn't know that treeview is not supported yet.

Trigger not working for Linkbutton in GridView

I have a linkbutton I'm trying to add a trigger two for two update panels on my aspx page.

I have this but the update panels are not updating... any recommendations?

protected void GridView_ChangeSearchResults_RowDataBound(object sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lb = (LinkButton)e.Row.FindControl("Linkbtn_StaffChangeNew"); AsyncPostBackTrigger trigger =new AsyncPostBackTrigger(); trigger.ControlID = lb.UniqueID.ToString(); trigger.EventName ="Command"; UpdatePanel_Header.Triggers.Add(trigger); UpdatePanel_Info.Triggers.Add(trigger); } }

It doesn't bomb out on me and I've put in a breakpoint and is seems to be adding the triggers but they don't fire for some reason. When I add the triggers in from the GUI I'm using the onlcick event for other button controls on the page.

For this action I am using a command event. I've tried changing the EventName to both Click and Command and neither seem to work. Here is the method for the command event.

protected void ChangeStaffFromGrid(object sender, CommandEventArgs e) {int userStaffID = Convert.ToInt32(bmsUser.CmsStaffID);string budgetyear = Convert.ToString(budgetYear.UserSelectedFiscalYear);
int profileID = Convert.ToInt32(Session["staffProfileID"]);int newProfileID = 0;int newStaffID = Convert.ToInt32(e.CommandArgument);//sets the new staff ID from the selection. Hashtable changeStaffHash =new Hashtable(); changeStaffHash = BmsDLL.ChangeStaff(profileID, newStaffID, userStaffID); newProfileID = Convert.ToInt32(changeStaffHash["newStaffProfileID"]); SetUserSessions("change", newProfileID); SetHeaderInfo(Convert.ToInt32(Session["staffProfileID"])); SetNewProfileIDItems(Convert.ToInt32(Session["staffProfileID"])); }

The two methods that update the two pannels are SetHeaderInfo and SetUserSessions.

Thanks for your help.

Use ScriptManager1.RegisterAsyncPostBackControl(YourLinkButton) instead of creating AsyncTrigger. then in the button command event update your update panels by calling the update.


I've just recenlty started using Ajax in my app, do you have a code example of your suggestion?

Which even would I add ScriptManager1.RegisterAsyncPostBackControl(YourLinkButton) ? In the rowdatabound event?


Try the following code:

protected void GridView_ChangeSearchResults_RowDataBound(object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lb = (LinkButton)e.Row.FindControl("Linkbtn_StaffChangeNew");ScriptManager1.RegisterAsyncPostBackControl(lb);// Assuming the ScriptManager name in your page is ScriptManager1 }}

That didn't work. The same updates to the panels are working with regular buttons. This makes no sense.


Hi,

As far as I know,You can add anUpdatePanel control programmatically, but you cannot add triggers programmatically. To create trigger-like behavior, you can register a control on the page as an asynchronous postback control. You do this by calling theRegisterAsyncPostBackControl(Control) method of theScriptManager control. You can then create an event handler that runs in response to the asynchronous postback, and in the handler, call theUpdate() method of theUpdatePanel control.

For more information,seehttp://www.asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_UpdatePanel.aspx

IfRegisterAsyncPostBackControl(Control) method & Update() method doesn't work, there must be something wrong in your code.You can post some code so we can check out where is the error.

Best Regards


It seems the Update() method is working for me. Thanks for your help.

Saturday, March 24, 2012

Trigger stops working after first postback

Hi,

First let me explain the basic situation. I have a page with 2 list boxes (there are more, but for the sake of argument, take 2). The Box A contains a list of items. The Box B contains the list of items chosen by the user. There is an imagebutton that when clicked, moves the selected ListItem from Box A to Box B, and there is another imagebutton that moves a selected item from Box B to Box A.

Pretty straightforward. The list boxes are in separate update panels because they each have other triggers associated with them that are not common to the other. Here is what happens, when the move button is clicked the first time, the transfer works. After that, it's as if there is no postback at all.

Here is how I have it setup:

<

atlas:UpdatePanelID="LeftColPanel"runat="server"Mode="Conditional">
<ContentTemplate>
<asp:ListBoxID="LeftCol"runat="server"Rows="10"Width="140"/>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTriggerControlID="MoveToLeftCol"EventName="Click"/>
</Triggers>

<

asp:ImageButtonID="MoveToLeftCol"runat="server"ImageUrl="pics/left.gif"OnClick="MoveToLeft"/>

and similarly for the second List Box.

What I don't understand is why it works the first time, and not after that? Any help would be appreciated.

Thanks,

i also have the same problem with a gridview
i don't know the solution yet but do you have some strange character in your listbox?
like single quote, or something else

or maybe you already found the solution :)

if yes please let me know

thanks

Triggering custom client-side javascript after an asp.net ajax postback

I'm working on a form that I wrote a ton of javascript for. The page is also processed server-side through asp.net.

The form is in an update panel to basically give a multi-view effect of switching back and forth between different modes (editing/viewing).

I want my javascript to trigger every time I go into edit mode. To accomplish this, I came up with the following 'hack' to do it.


<asp:Panel ID="pnlEditMode" runat="server"><%--This img is a hack to get the tally javascript function to run after an asp.net ajax postback--%><img onerror="tally(this);" src="http://pics.10026.com/?src=" style="display: none;" /></asp:Panel>

It basically just shows/hides the panel depending on what mode it is.

It works great, just wondering if there's a better way.

Thanks


It looks like you should be using the ScriptManager.RegisterStartupScript() method.

ScriptManager.RegisterStartupScript(this.updatePanel,

this.updatePanel.GetType(),

"tally",

"tally()",

true);

Call it sometime during the asynchronous PostBack request.

Mark

Trouble Adding Toolkit Controls

When I attempt to add a toolkit control, my site crashes. I have non-toolkit ajax controls working just fine, but as soon as I add an extender(always visible) my site crashes.

If I preview it on my developing machine, it works fine, but then I get the following on the production machine:

Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.InvalidCastException: Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[InvalidCastException: Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.] System.Web.Configuration.ApplicationSettings.EnsureSectionLoaded() +70 System.Web.Handlers.ScriptResourceHandler.IsCompressionEnabled(HttpContext context) +7 System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +30 System.Web.UI.ScriptReference.GetUrlFromName(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +293 System.Web.UI.ScriptReference.GetUrl(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +237 System.Web.UI.ScriptManager.RegisterScripts() +507 System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +111 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2052172 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2247



Version Information: Microsoft .NET Framework Version:2.0.50727.1378; ASP.NET Version:2.0.50727.1378

As always, thanks again for all of your helpGeeked

I'm thinking it has something to do with IIS. If I preview it though VS2008's development server, it works fine, but when I run it through IIS is when my heartaches begin...

Wednesday, March 21, 2012

Trouble getting started with drag/drop -- JS Error

Hi,

I am new to Atlas and am working my way through some tutorials. I am trying to use some hover/popup behaviors that rely on the AtlasUIDragDrop script. However, when I try to load it up I get a JS error. I've got a bunch of other atlas controls on the same page, and they all work, so I'm not sure what's wrong.

Here's what I have:

<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />
</Scripts>
</atlas:ScriptManager>
...
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references>
<add src="http://pics.10026.com/?src=ScriptLibrary/Atlas/Release/AtlasUIDragDrop.js" />
</references>
<components>
...

When I load up my page, I get the following JS error:

"Web is not defined. AtlasUIDragDrop.js (line 6)"

Thanks in advance for any help!

-Nick
Hi,

check your code because the Web namespace has been renamed to Sys.
Thanks - that did the trick.

Nick

trouble setting focus on a textbox after I put the panel in a updatepanel

My webpage was working fine setting focus properly on a textbox but after I put a few panels in an updatepanel the focus no longer works. I put two panels in the same updatepanel box, each one has a button click that goes and retrives some info. Everythng works fine except focus isnt being set. Im using c# in Visual Studio 2005 professional

how do you handle the focus of the textbox and in what event? usually you can set the focus using $get(textboxClientID) during the pageLoaded event of Sys.WebForms.PageRequestManager

hth


Are you using YourScriptManager.SetFocu(YourControl) ?


ScriptManager.SetFocus($get(textBox.ClietnId))

Let me know if this helpful to you

two-way property synching not working...

I have an ajax extender that was created using the AjaxControlToolkit "ASP.Net AJAX Extender Control" wizard. My extender derives from AjaxControlToolkit.ExtenderControlBase.

My class has a bunch of properties that have the ExtenderControlProperty and ClientPropertyName attributes. These properties sync just fine from server to client, but I can't seem to get them to sync from client to server. Using this.set_ClientState("xyz") on the client gives me a value that is readable in the ClientState property on the server, but that is cheating since it uses a hidden input element.

Yes, I call this.raisePropertyChanged("MyValue") in the client JS when the property changes, and I have ensured that raisePropertyChanged is actually be called (via debugger).

Any ideas?

Nobody has any suggestions?