Click here to Skip to main content
15,888,090 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: onsubmit event Pin
jkirkerx9-Sep-14 4:22
professionaljkirkerx9-Sep-14 4:22 
QuestionSample code to post a asp.net forms data to third party API in XML input Pin
Roberts Techie7-Sep-14 19:07
Roberts Techie7-Sep-14 19:07 
GeneralRe: Sample code to post a asp.net forms data to third party API in XML input Pin
Kornfeld Eliyahu Peter7-Sep-14 20:51
professionalKornfeld Eliyahu Peter7-Sep-14 20:51 
GeneralRe: Sample code to post a asp.net forms data to third party API in XML input Pin
Richard MacCutchan7-Sep-14 21:27
mveRichard MacCutchan7-Sep-14 21:27 
GeneralRe: Sample code to post a asp.net forms data to third party API in XML input Pin
Kornfeld Eliyahu Peter7-Sep-14 21:57
professionalKornfeld Eliyahu Peter7-Sep-14 21:57 
GeneralRe: Sample code to post a asp.net forms data to third party API in XML input Pin
Richard MacCutchan7-Sep-14 22:15
mveRichard MacCutchan7-Sep-14 22:15 
AnswerRe: Sample code to post a asp.net forms data to third party API in XML input Pin
Bernhard Hiller7-Sep-14 22:06
Bernhard Hiller7-Sep-14 22:06 
QuestionHow to implement a Treeview / Form interface. Pin
Wierdbeard656-Sep-14 4:21
Wierdbeard656-Sep-14 4:21 
Hi,
First up, sorry if I haven't used the correct name for this interface style in the title. I'm not sure if there even is a correct name! What I am trying to do is to have a treeview on the left of the screen and an AJAX panel on the right. When a node is selected, a User Control is added to the panel (different controls depending on the type of the node).

This part works.

My problem is twofold.

1. If I select a node in the tree, the SelectedNodeChanged event fires, and causes the User Control to be correctly displayed. If, however, I click on the node that is already selected, the User Control disappears. I can only assume AJAX is updating the panel, but I can't figure out why. There doesn't appear to be an OnClick event for a TreeView..

2. When I click on the OK or Cancel buttons within my User Control, I want the postback to update my application and then leave the node selected with the User Control still displayed (Obviously, Cancel results in the contents being wiped...) Again, clicking the button causes the User Control to disappear.

Code:
Main Page
ASP.NET
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="HomeLink">
        <asp:HyperLink ID="HyperLink1" runat="server" CssClass="home" ImageUrl="~/Images/105329-3d-glossy-orange-orb-icon-business-home5.png"
            NavigateUrl="~/Default.aspx">
        </asp:HyperLink>
    </div>
    <asp:Panel ID="TreeArea" runat="server" CssClass="TreeArea">
        <%-- Here ExpandDepth="0" for eleminates the expansion of the added treenodes --%>
        <asp:TreeView ID="TreeViewSettings" runat="server" ExpandDepth="0" PopulateNodesFromClient="False"
            CssClass="TreeViewSettings" OnSelectedNodeChanged="TreeViewSettings_SelectedNodeChanged">
        </asp:TreeView>
    </asp:Panel>
    <asp:Panel ID="EditFormArea" runat="server" CssClass="SettingsFormArea">
        <asp:UpdatePanel ID="UpdatePanelEdit" runat="server">
            <ContentTemplate>
                <asp:Panel ID="PanelEdit" runat="server">
                </asp:Panel>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="TreeViewSettings" EventName="SelectedNodeChanged">
                </asp:AsyncPostBackTrigger>
            </Triggers>
        </asp:UpdatePanel>
    </asp:Panel>
</asp:Content>


C#
protected void TreeViewSettings_SelectedNodeChanged(object sender, EventArgs e)
{
    reload();
}
protected void reload(){
    TreeNode selection = TreeViewSettings.SelectedNode;
    string[] SelectedDetails = selection.Value.Split(new char[] {'|'});
    RegionEditor RegionEditorForm = LoadControl("~/TheSettings/RegionEditor.ascx") as RegionEditor;
    RegionEditorForm.RegionID = int.Parse(SelectedDetails[1]);
    RegionEditorForm.CancelClick += new EventHandler(RegionEditorForm_CancelClick);
    PanelEdit.Controls.Add(RegionEditorForm);
    AsyncPostBackTrigger CancelTrigger = new AsyncPostBackTrigger();
    CancelTrigger.ControlID = RegionEditorForm.UniqueID;
    CancelTrigger.EventName = "CancelClick";
    UpdatePanelEdit.Triggers.Add(CancelTrigger);
}
void RegionEditorForm_CancelClick(object sender, EventArgs e)
{
    reload();
}


User Control:
ASP.NET
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RegionEditor.ascx.cs"
    Inherits="Shedulinator.TheSettings.RegionEditor" %>
<% if (false)
   { %>
<link rel="Stylesheet" type="text/css" href="../Styles/Site.css" />
<% } %>
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/106660-3d-glossy-orange-orb-icon-transport-travel-compass2.png"
    CssClass="SettingsIcon" />
<asp:Panel ID="Panel1" runat="server" CssClass="SettingsFormPanel">
    <asp:Label ID="LabelRegion" runat="server" Text="Region Name:"></asp:Label>
    <asp:TextBox ID="TextBoxRegionName" runat="server"></asp:TextBox>
    <asp:Button ID="ButtonCancel" runat="server" CssClass="SettingsButton" 
        Text="Cancel" onclick="ButtonCancel_Click" />
    <asp:Button ID="ButtonOK" runat="server" CssClass="SettingsButton" Text="OK" 
        onclick="ButtonOK_Click" />
</asp:Panel>

C#
public partial class RegionEditor : System.Web.UI.UserControl
{
    public event EventHandler CancelClick;
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void ButtonCancel_Click(object sender, EventArgs e)
    {
        if (CancelClick != null)
        {
            CancelClick(this, new EventArgs());
        }
    }
}


Ideas, anyone?

Thanks!
AnswerRe: How to implement a Treeview / Form interface. Pin
jkirkerx6-Sep-14 12:30
professionaljkirkerx6-Sep-14 12:30 
GeneralRe: How to implement a Treeview / Form interface. Pin
Wierdbeard656-Sep-14 15:21
Wierdbeard656-Sep-14 15:21 
GeneralRe: How to implement a Treeview / Form interface. Pin
jkirkerx6-Sep-14 16:20
professionaljkirkerx6-Sep-14 16:20 
GeneralRe: How to implement a Treeview / Form interface. Pin
Wierdbeard6512-Sep-14 6:54
Wierdbeard6512-Sep-14 6:54 
QuestionNeed to POST xml data to web device w/ c# ASPX Pin
Member 110616635-Sep-14 5:36
Member 110616635-Sep-14 5:36 
QuestionAsp.net GridView with JQuery Pin
Member 106549793-Sep-14 20:41
Member 106549793-Sep-14 20:41 
QuestionRe: Asp.net GridView with JQuery Pin
ZurdoDev5-Sep-14 6:19
professionalZurdoDev5-Sep-14 6:19 
QuestionConverting Word document to HTML page Pin
meeram393-Sep-14 19:14
professionalmeeram393-Sep-14 19:14 
SuggestionRe: Converting Word document to HTML page Pin
Kornfeld Eliyahu Peter3-Sep-14 20:14
professionalKornfeld Eliyahu Peter3-Sep-14 20:14 
QuestionEncoding password sent to MVC web service reports vulnerability issues Pin
Stephen Holdorf3-Sep-14 8:22
Stephen Holdorf3-Sep-14 8:22 
QuestionAjax call Error when using FileStream in code Pin
pawan Jha19883-Sep-14 2:59
pawan Jha19883-Sep-14 2:59 
AnswerRe: Ajax call Error when using FileStream in code Pin
Richard Deeming3-Sep-14 3:32
mveRichard Deeming3-Sep-14 3:32 
GeneralRe: Ajax call Error when using FileStream in code Pin
ZurdoDev3-Sep-14 3:36
professionalZurdoDev3-Sep-14 3:36 
GeneralRe: Ajax call Error when using FileStream in code Pin
pawan Jha19884-Sep-14 0:54
pawan Jha19884-Sep-14 0:54 
QuestionThe request failed with HTTP status 401: Unauthorized Pin
Member 101656822-Sep-14 2:38
Member 101656822-Sep-14 2:38 
AnswerRe: The request failed with HTTP status 401: Unauthorized Pin
Jameel VM2-Sep-14 3:41
Jameel VM2-Sep-14 3:41 
GeneralRe: The request failed with HTTP status 401: Unauthorized Pin
Member 101656822-Sep-14 20:07
Member 101656822-Sep-14 20:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.