converting the frontend in a way, postback works

Hi;

I have a rather complex form that I need to convert in a way that once a controller is clicked, i want a postback action happens that I can check what controller is clicked.

When the user clicks on "Add New", another windows content is appearing below the grid.

I can change return false to return true below which is fine for postback but then I lose the form and it goes into a state as if "Add New" button is not clicked.

Can you help me?

<%@ Control Language="C#" AutoEventWireup="true" Inherits="jazziiiloveWebApplication.UI.ExperimentGroup.News_News" Codebehind="News.ascx.cs" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<%--<asp:UpdatePanel ID="upAB" runat="server">
    <ContentTemplate>--%>
<script type="text/javascript">
    function HideMessage() {
        $('#<%=lblMessage.ClientID %>').fadeOut("medium");
    }

    function HideEditForm() {
        $("#<%=EditForm.ClientID %>").fadeOut("slow");
        ClearAll();
        return false;
    }

    function ShowEditForm() {
        $("#<%=EditForm.ClientID %>").fadeIn("slow");
        ClearAll();

        $("#<%=trPicture.ClientID %>").attr("style", "display:none");

        return false;
    }

    function ClearAll() {
        var lblMessage = document.getElementById("<%=lblMessage.ClientID %>");
        lblMessage.innerHTML = "";

        document.getElementById("<%=txtTitle.ClientID %>").value = "";
        document.getElementById("<%=txtShortDescription.ClientID %>").value = "";
        document.getElementById("<%=txtDescription.ClientID %>").value = "";
        document.getElementById("<%=txtLink.ClientID %>").value = "";
        document.getElementById("<%=hfEditID.ClientID %>").value = "0";

        HideMessage();
    }
</script>
<table width="100%">
    <tr>
        <td>
            <h3>
                <asp:Literal ID="ltrnews" Text="<%$Resources:Swedish,News %>" runat="server">
                </asp:Literal></h3>
        </td>
        <td align="right">
            <asp:Button ID="btnAddNew" runat="server" Text="<%$Resources:Swedish,add %>" OnClientClick="return ShowEditForm()" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <hr />
        </td>
    </tr>
</table>
<asp:Label ID="lblMessage" runat="server" CssClass="success_msg"></asp:Label>
<asp:HiddenField ID="hfEditID" runat="server" Value="0" />
<div style="height: 3px">
</div>
<table>
    <tr>
        <td>
            <asp:Literal ID="Literal12" Text="<%$Resources:Swedish,language %>" runat="server">
            </asp:Literal>:&nbsp;
            <asp:DropDownList ID="drpGridLanguage" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drpGridLanguage_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            <asp:GridView ID="grdControl" runat="server" AutoGenerateColumns="False" SkinID="GridAdmin"
                OnRowCommand="grdControl_RowCommand" OnRowDataBound="grdControl_RowDataBound"
                AllowPaging="True" PageSize="10" OnPageIndexChanging="grdControl_PageIndexChanging"
                CssClass="AdminGrid">
                <Columns>
                    <asp:TemplateField HeaderText="<%$Resources:Swedish,Title1 %>">
                        <ItemTemplate>
                            <asp:Label ID="lblNewsTitle" runat="server"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Link" HeaderText="<%$Resources:Swedish,Link %>" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:ImageButton ID="btnEdit" runat="server" CommandName="Modify" CommandArgument='<%#Eval("NewsID") %>'
                                            ImageUrl="~/App_Themes/default/images/edit_ico.png" CausesValidation="false"
                                            Style="float: right" />
                                    </td>
                                    <td>
                                        <asp:ImageButton ID="btnDelete" runat="server" CommandName="Remove" CommandArgument='<%#Eval("NewsID") %>'
                                            ImageUrl="~/App_Themes/default/images/delete_ico.png" CausesValidation="false"
                                            OnClientClick="return confirm('Are you sure wants to delete?')" Style="float: right" />
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    <asp:Literal ID="ltrnof" Text="<%$Resources:Swedish,record %>" runat="server">
                    </asp:Literal>
                </EmptyDataTemplate>
            </asp:GridView>
        </td>
    </tr>
</table>
<div style="height: 15px">
    <hr />
</div>
<div id="EditForm" runat="server" style="display: none; border: 1px solid #ccc; margin-bottom: 10px;">
    <table cellpadding="3" cellspacing="3" style="background-color: #fff;">
        <tr>
            <td colspan="4">
                <asp:ValidationSummary ID="vsCategory" runat="server" ValidationGroup="ManageNews" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Literal ID="ltrtlt" Text="<%$Resources:Swedish,Title %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:TextBox ID="txtTitle" runat="server" CssClass="textnew"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ControlToValidate="txtTitle"
                    ErrorMessage="<%$Resources:Swedish,entertlt %>" Text="*" ValidationGroup="ManageNews"></asp:RequiredFieldValidator>
            </td>
            <td>
                <asp:Literal ID="Ltrcat" Text="<%$Resources:Swedish,Category1 %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:DropDownList ID="drpCategory" runat="server" CssClass="textnew">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Literal ID="Literal1" Text="<%$Resources:Swedish,Link1 %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:TextBox ID="txtLink" runat="server" CssClass="textnew"></asp:TextBox>
                <asp:RegularExpressionValidator ID="revLink" runat="server" ControlToValidate="txtLink"
                    ErrorMessage="<%$Resources:Swedish,linkofref %>" Text="*" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?"
                    ValidationGroup="ManageNews">*</asp:RegularExpressionValidator>
            </td>
            <td>
                <asp:Literal ID="Literal2" Text="<%$Resources:Swedish,Video %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:FileUpload ID="fuVideo" runat="server" />
                <asp:Button ID="btnVideoUpload" runat="server" Text="<%$Resources:Swedish,Upload %>"
                    OnClick="btnUploadVideo_Click" ValidationGroup="UploadVideo" />
                <asp:RegularExpressionValidator ID="revVideo" runat="server" ControlToValidate="fuVideo"
                    ErrorMessage="<%$Resources:Swedish,plzvideo %>" ValidationExpression="(.*?)\.(flv|mp4)$"
                    ValidationGroup="UploadVideo">
                </asp:RegularExpressionValidator>
                <br />
                <span class="HelpText">
                    <asp:Literal ID="Literal10" Text="<%$Resources:Swedish,Uploadfl %>" runat="server">
                    </asp:Literal></span>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Literal ID="Literal3" Text="<%$Resources:Swedish,sdescription %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:TextBox ID="txtShortDescription" runat="server" MaxLength="500" TextMode="MultiLine"
                    CssClass="textnew" Style="height: 50px;"></asp:TextBox>
            </td>
            <td>
                <asp:Literal ID="Literal4" Text="<%$Resources:Swedish,Picture %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:FileUpload ID="fuImage" runat="server" />
                <asp:Button ID="btnUpload" runat="server" Text="<%$Resources:Swedish,Upload %>" OnClick="btnUpload_Click"
                    ValidationGroup="UploadPicture" />
                <asp:RegularExpressionValidator ID="regexValidator" runat="server" ControlToValidate="fuImage"
                    ErrorMessage="<%$Resources:Swedish,plzimg %>" ValidationExpression="(.*?)\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF)$"
                    ValidationGroup="UploadPicture">
                </asp:RegularExpressionValidator>
                <br />
                <span class="HelpText">
                    <asp:Literal ID="Literal9" Text="<%$Resources:Swedish,imgdply %>" runat="server">
                    </asp:Literal></span>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Literal ID="Literal11" Text="<%$Resources:Swedish,Language %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:DropDownList ID="drpLanguage" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drpLanguage_SelectedIndexChanged">
                </asp:DropDownList>
            </td>
            <td>
                <asp:Literal ID="Literal5" Text="<%$Resources:Swedish,ShowReferenceLink %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:CheckBox ID="chkShowReferenceLink" runat="server" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Literal ID="Literal6" Text="<%$Resources:Swedish,Reporter %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:TextBox ID="txtReporter" runat="server" MaxLength="50" CssClass="textnew"></asp:TextBox>
            </td>
            <td>
                <asp:Literal ID="Literal7" Text="<%$Resources:Swedish,ShowReporter %>" runat="server">
                </asp:Literal>
            </td>
            <td>
                <asp:CheckBox ID="chkShowReporter" runat="server" />
            </td>
        </tr>
        <tr>
            <td valign="top" colspan="4">
                <asp:Literal ID="Literal8" Text="<%$Resources:Swedish,Description %>" runat="server">
                </asp:Literal>
                <br />
                <br />
                <%--<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" CssClass="textnew_multi" style="display:none"></asp:TextBox>--%>
                <CKEditor:CKEditorControl ID="txtDescription" runat="server" BaseHref="~/ckeditor"
                    Height="200px" Width="950px"></CKEditor:CKEditorControl>
            </td>
        </tr>
        <tr id="trPicture" runat="server">
            <td valign="top" colspan="4">
                <div style="height: 370px; overflow: scroll">
                    <asp:DataList ID="dlPictures" runat="server" RepeatColumns="5" RepeatDirection="Horizontal"
                        OnItemCommand="dlPictures_ItemCommand" Width="900px">
                        <ItemTemplate>
                            <div class="divgallery">
                                <img src='<%#Page.ResolveUrl(Eval("Path").ToString()) %>' alt="" height="150" width="165" />
                                <center>
                                    <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/App_Themes/default/images/delete_ico.png"
                                        OnClientClick="return confirm('Are you sure wants to delete?')" CommandArgument='<%#Eval("ImageID") %>'
                                        CommandName="Remove" />
                                </center>
                            </div>
                        </ItemTemplate>
                    </asp:DataList>
                </div>
                <%--<a style="font-size: larger" href="javascript:$('#<%=FileUpload1.ClientID%>').fileUploadStart()">
                    Start Upload</a>&nbsp; |&nbsp;<a style="font-size: larger" href="javascript:$('#<%=FileUpload1.ClientID%>').fileUploadClearQueue()"><b>Clear</b>
                    </a>--%>
            </td>
        </tr>
        <tr>
            <td colspan="4" align="right" style="padding-right: 10px">
                <asp:Button ID="btnSave" runat="server" Text="<%$Resources:Swedish,Save %>" OnClick="btnSave_Click"
                    ValidationGroup="ManageNews" />
                <asp:Button ID="btnCancel" runat="server" Text="<%$Resources:Swedish,Cancel %>" CausesValidation="false"
                    OnClientClick="return HideEditForm()" />
            </td>
        </tr>
    </table>
</div>
<%--    </ContentTemplate>
</asp:UpdatePanel>--%>

Open in new window

LVL 12
jazzIIIloveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kblauCommented:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication11
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [WebMethod]
        public static void GetControllerSource(userControl u)
        {
            
        }
    }

    public class userControl
    {
        public string Name { get; set; }
    }
}

Open in new window


function ShowEditForm() {
        $("#<%=EditForm.ClientID %>").fadeIn("slow");
        ClearAll();

        $("#<%=trPicture.ClientID %>").attr("style", "display:none");

       
        var userControl = {};
        userControl.Name = "News.ascx";

        var udata = { "u": userControl };
        

        $.ajax({
            url: 'Default.aspx/GetControllerSource',
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(udata),
            dataType: "json",
            success: function (result) {
               
            }
            ,
            error: function (e) {
                alert(e);
            }
        });

        return false;
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jazzIIIloveAuthor Commented:
Clean approach, swift expert
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.