ASP TreevIew Control and Forms Authentication

S

Srinivasa Raghavan

Hi All,


I have some doubts on the Treeview control and Form
Authentication

1) will Form Authentication work if cookies are disabled.
2) I have problem in the following code (TreeView Control
with checkbox)

When I click on the checkbox in treeview with autopostback
false,the count in view state is going wrong when uncheck
and check .Please suggest any solutions.

StringCollection nodesChecked;
if(!Page.IsPostBack)
{
ViewState["Selected"] =
new StringCollection();
}
else
{
nodesChecked = new
StringCollection();
nodesChecked =
(StringCollection)ViewState["Selected"];
}


private void TreeView1_Check(object sender,
Microsoft.Web.UI.WebControls.TreeViewClickEventArgs e)
{
TreeView
treeView;
TreeNode
node;
string
strNodeChecked;

treeView =
(TreeView)sender;

strNodeChecked = e.Node;
node =
treeView.GetNodeFromIndex(strNodeChecked);

// the
node will have been checked or unchecked
if
(node.Checked)
{

nodesChecked.Add(node.Text);
}
else
{

nodesChecked.Remove(node.Text);
}

ViewState
["Selected"] = nodesChecked;

}

}
 
M

Mark Fitzpatrick

Looking at number two first. If you have autopostback set to false,
something like IE isn't necessarily going to post back to the server. I know
it's annoying to round-trip things, but setting autopostback to on is the
best option for a treeview where you have to interact, such as when you're
building dynamic nodes or when you're using the checkbox. To see if it's
working, you can add a response.write at the beginning of your check event
handler for the checkbox to write something like "checked" everytime the
event fires. That will definitely help you determine if the event is really
firing or not. Also note that the treeview will have very different
behaviors on Navigator, or other non-IE browsers.

Forms authentication uses cookies to store an authentication cookie on the
browser so it pretty much needs cookies to store the authentication.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top