Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Wednesday, March 28, 2012

Ajax based custom control with web service

I want to create a simple reusable search pane control.

The idea is to have a textbox and a button. When you press the button you trigger an AJAX call to the server with the textbox value as parameter. The AJAX call then bridge the request to a web service that perform the database search an return a dataset. The dataset is then binded to a repeater in a updatepanel to display result. I've been using a WCF service for the web service.

This work fine if I host the textbox, the button and the result detail ascx file in a ASP.NET Ajax Enabled WebSite.

I try to move this part to a user web control, including the ascx files in resources. I hit the following problem: When I include the control (compiled assembly) in a ASP.Net Ajax Enabled Web site, the control display correctly but the AJAX call fail.

I think that the ScriptManagerProxy setting the AJAX service in my user control fails to find the path of the asmx ServerScript definition within the assembly.

Do you have any idea to make this work smoothly, ideally with only the assembly included in the website project?

Thanks in advance for your help

mavrj

Web user control is not only an assembly, which should include .ascx file and.ascx.cs or.ascx.vb file.There is only one asp:ScriptManager in a Ajax web form. I once tested a Ajax enabled web user control and placed it in a common web form.I found it worked fine. Can you post some codes here? We are going to test it.

Monday, March 26, 2012

Ajax application not working when deployed to web server

I installed the extender and then the toolkit and was able to create the sample application described here:http://ajax.asp.net/ajaxtoolkit/Walkthrough/UsingSampleExtender.aspx

However, when I deploy the webpage to my company's web server I get the following error when I try to run it:

Server Error in '/ajaxtest' Application.

Configuration Error

Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message:Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (E:\WebSites\ajaxtest\web.config line 41)

Source Error:

Line 39: </httpHandlers>Line 40: <httpModules>Line 41: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>Line 42: </httpModules>Line 43: </system.web>


Source File:E:\WebSites\ajaxtest\web.config Line:41


The file it is referencing (E:\WebSites\ajaxtest\web.config) is there. Does anyone have any idea what's going on? I've Googled the problem and searched on here but nothing seems to work.

Thanks in advance!

Do you have System.Web.Extensions.dll in the bin directory in the server?

Do you mean the bin application of my AJAX enabled web app?

If so, that particular DLL is not in the bin folder, but it's not in the bin folder on my local machine either and it runs fine there. It just doesn't run on the web server.


If you don't have a bin of your application in the bin folder, maybe it's because you don't have a webApp project but a web site project. But, in both cases, you should have more dll's in the bin folder and that dll's should be copied to the bin folder on the server!

That's true. It is a web site project and not a web app project. However, I do have a bin folder for the application on my development machine and the server. When run on my development machine the application works, but when run on the server it doesn't. And neither bin folder has the dll you mentioned.

I'm sorry if I was confusing before.

Regardless, I will see about getting that dll into the proper folder and see what happens from there. Thanks again for your help and advice!


The dll you need should be here:

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\System.Web.Extensions.dll

Put it on bin folder on server and it should work, I hope. :P


SWEET! That did the trick!

Thanks a million, Agapito! I really appreciate it.


Gracias! Friend! it worked.

Yes

Saturday, March 24, 2012

Ajax and querystring parameter

Hi,

I am developing a new application with Ajax.

I must create a new aspx page that have two mode: "view" or "modify" and show some products based on their ID.

In not Ajax context I use the query string with parameters to change the mode and the ID of products and it is very simple. I change the query string using Response.Redirect("same page + new paramaters")

With Ajax I think to use some session variables to manage the mode of page and ID of products...

Is the correct solution?

Since the view/modify is likely tied to the authenticated user, I'd suggest use encrypted ViewState variables to store the productid and page mode. It won't expire compared to the SessionState.


Ok, but I have the necessity to pass some values (modify/view, productId) to this page.

Is the viewstate accessible between pages?

If I store an object in viewstate and then there is a redirect to a new page, is the object value accessible from new page?

Thank you.


I am using the session to tranfer object between pages and then I use the viewstate for postpack in the same page.

I have a problem.

I click in a button and in onclick method I change viewstate "mode" value from "view" to "modify"...

When in the Page_Load event I test the value of viewstate mode, it is still "view" instead of "modify". The viewState value change only on next postback...i must click two times to change page modality from view to modifiy.

How can I resolve this problem?


Ok, I have inserted the check in the Page_PreRender method and now it is working fine.

I did not remember that any code that is dependent on a control event should be put into PreRender method.


If you need to keep variable value between pages, using sessionstate is one solution, keep in mind that session will expire. You can also use database to handle temporary data storage. A new feature in ASP.NET 2.0 is the postback to another page, read this article to see if it fits what you wanted:http://msdn2.microsoft.com/en-us/library/6c3yckfw.aspx

For viewstate, it only belong to the current page. The value will not be carried over to another page.

Ajax and MasterPage issues (tags like scriptManager and html - not recognized)

I am having problem with AJAX Toolkit and MasterPages.

When I create a new Content Page and use html tags or ahax scriptManager I recevied lots of errors.

I cannot seem to get this resolved.

Here find below example I am working on - none of the html or scriptManager stuff for ajax is being recongnised.

Please assist.

File Sample

------------

<%@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="laz.aspx.cs"Inherits="laz"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

</asp:Content>

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

<scriptrunat="server">

protectedvoid btnRefresh_Click(object sender,EventArgs e)

{

}

</script>

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

<headid="Head1"runat="server">

<title>Untitled Page</title>

<linkhref="StyleSheet.css"rel="stylesheet"type="text/css"/>

</head>

<body>

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<asp:PanelID="Panel1"runat="server"CssClass="modalPopup"Height="50px"Width="235px"style="display:none"DefaultButton="btnOk">

<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<%=DateTime.Now.ToString() %>

<divstyle="display:none">

<asp:ButtonID="btnRefresh"runat="server"Text="Refresh"OnClick="btnRefresh_Click"/>

</div>

</ContentTemplate>

</asp:UpdatePanel>

<asp:ButtonID="btnCancel"runat="server"Text="Cancel"/>

<asp:ButtonID="btnOk"runat="server"Text=" OK "/>

</asp:Panel>

<asp:ButtonID="Button2"runat="server"Text="Button"Enabled="false"style="display:none"/>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="Button2"PopupControlID="Panel1"CancelControlID="btnCancel"DropShadow="true"BackgroundCssClass="modalBackground">

</ajaxToolkit:ModalPopupExtender>

<inputid="Button3"type="button"value="Click Me"onclick="showModalPopup()"/>

<scripttype="text/javascript"language="javascript">

function showModalPopup(){

$get("<%=btnRefresh.ClientID %>").click();

$find("<%= this.ModalPopupExtender1.ClientID %>").show();

}

</script>

</form>

</body>

</html>

...........?

why are all the tags outside the <asp:Content? Aren't they suppose to be inside?


Honestly is does not matter if the content is inside the ASP tag or not. I was testing the contents outside. Here find the same results with ASP tag and content inside.

With the below I receive 7 errors

1. Only content controls allowed directly in content page. LINE 16

2. Validation XHTML 1.0 Element body cannot be in nested within <div> - I do not have div tag in ths aspx page but maybe it comes from the masterpage? LINE 14

3. Element Script Manager not a knwon element LINE 16

4. Element UpdatePanel unknown element LINE 19

5. Validation Element contenttemplate is not supported LINE 20

6. Element Button is not a known element Line 23

<%@.PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="laz.aspx.cs"Inherits="laz"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<scriptrunat="server">

protectedvoid btnRefresh_Click(object sender,EventArgs e)

{

}

</script>

<body> LINE 14

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server"> LINE 16

</asp:ScriptManager>

<asp:PanelID="Panel1"runat="server"CssClass="modalPopup"Height="50px"Width="235px"style="display:none"DefaultButton="btnOk">

<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional"> LINE 19

<ContentTemplate> LINE 20

<%=DateTime.Now.ToString() %>

<divstyle="display:none">

<asp:ButtonID="btnRefresh"runat="server"Text="Refresh"OnClick="btnRefresh_Click"/> LINE 23

</div>

</ContentTemplate>

</asp:UpdatePanel>

<asp:ButtonID="btnCancel"runat="server"Text="Cancel"/>

<asp:ButtonID="btnOk"runat="server"Text=" OK "/>

</asp:Panel>

<asp:ButtonID="Button2"runat="server"Text="Button"Enabled="false"style="display:none"/>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="Button2"PopupControlID="Panel1"CancelControlID="btnCancel"DropShadow="true"BackgroundCssClass="modalBackground">

</ajaxToolkit:ModalPopupExtender>

<inputid="Button3"type="button"value="Click Me"onclick="showModalPopup()"/>

<scripttype="text/javascript"language="javascript">

function showModalPopup(){

$get("<%=btnRefresh.ClientID %>").click();

$find("<%= this.ModalPopupExtender1.ClientID %>").show();

}

</script>

</form>

</body>

</asp:Content>


from what you have here is that you have a <body> and <form> tags; those normally are already declared in the MasterPage. Check it again.


Yes I added the tags in Master page and removed from content page.

Also I added a masterpage.master.vb file and applied the imports which solved the issue with the scriptmanager.

Wednesday, March 21, 2012

Ajax and buttons

well, im new to AJAX, but there's something i don't understand. If I put a button and a label inside an updatepanel, create a global int i=1, and onclick I do

i++;

label1.Text= i.ToString();

when I click, this action is only accruing once. afterwards when i click it's still stuck on 2. What am I doing wrong?

ty.

Hi, probably your label1 control isn't in update panel's content template. If you have a button into a UpdatePanel, when you perform click it will update only the content inside UpdatePanel.


Smile

HI

1) Are u add the label in the Update Panel.

2) Try with declare the variable as static int.due to the declaration also the problem occurs..



There is no concept of a "global" variable on an aspx page. It will reinitialize on each postback. You could either save the value to the ViewState or to a Session object.

You could always just look at the value of the label, increment that, and save it back to the label.


Well, i tried with viewstate and that didnt work either. the button and the label are both inside the update panel. the c# code is:

protected void Page_Load(object sender, EventArgs e) { ViewState["i"] = 1; Label1.Text = ViewState["i"].ToString(); }protected void bt_next_Click(object sender, EventArgs e) { ViewState["i"] =int.Parse(ViewState["i"].ToString()) + 1; Label1.Text = ViewState["i"].ToString(); }
when I click the button it increases to 2, but afterwards the next click doesnt change it to 3.


SpriteSODA:

Well, i tried with viewstate and that didnt work either. the button and the label are both inside the update panel. the c# code is:

protected void Page_Load(object sender, EventArgs e) { ViewState["i"] = 1; Label1.Text = ViewState["i"].ToString(); }protected void bt_next_Click(object sender, EventArgs e) { ViewState["i"] =int.Parse(ViewState["i"].ToString()) + 1; Label1.Text = ViewState["i"].ToString(); }
when I click the button it increases to 2, but afterwards the next click doesnt change it to 3.

solved it by checking postback in the page_load :)

Ajax Accordion, Page.IsPostBack Problem

Hi all, I have a problem with the Ajax Accordion. Basiclly I use the Accordion to create to pane where the top pane is a submit form, and the bottom pane contains a grid view to view the results of the submitted data from an Access database.

Here is the front-end code:

1 <form id="form1" runat="server">2 <asp:ScriptManager ID="ScriptManager1" runat="server" />3 <div>4 <asp:UpdatePanel ID="UpdatePanel" runat="server">5 <ContentTemplate>6 <ajaxToolkit:Accordion ID="MyAccordion" runat="server" SelectedIndex="0"7 HeaderCssClass="accordionHeader" ContentCssClass="accordionContent"8 FadeTransitions="false" FramesPerSecond="40" TransitionDuration="250"9 AutoSize="None" RequireOpenedPane="true" SuppressHeaderPostbacks="true">10 <Panes>11 <ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">12 <Header><a href="http://links.10026.com/?link=" class="accordionLink">Insert New Task</a></Header>13 <Content>14 <asp:Label runat="server" ID="lblName" Text="Name"></asp:Label>15 <asp:TextBox runat="server" ID="txtName"></asp:TextBox>16 <asp:Button runat="server" ID="btnSubmit" Text="Submit!" OnClick="OnSubmit"/>17 </Content>18 </ajaxToolkit:AccordionPane>19 <ajaxToolkit:AccordionPane ID="AccordionPane2" runat="server">20 <Header><a href="http://links.10026.com/?link=" class="accordionLink">Display Task</a></Header>21 <Content>2223 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true">24 <EmptyDataTemplate>25 <asp:Label runat="server" ID="lblBlank" Text="No Data!"></asp:Label>26 </EmptyDataTemplate>27 </asp:GridView>2829 </Content>30 </ajaxToolkit:AccordionPane>31 </Panes>32 </ajaxToolkit:Accordion>33 </ContentTemplate>34 </asp:UpdatePanel>35 </div>36 </form>

Here is my code-behind:

1public partialclass _Default : System.Web.UI.Page2{34protected void Page_Load(object sender, EventArgs e)5 {6if (!Page.IsPostBack)7 BindGrid();89 }1011protected void OnSubmit(object sender, EventArgs e)12 {13 TextBox ctrl = (TextBox)this.FindControl("UpdatePanel").FindControl("MyAccordion").FindControl("AccordionPane1").FindControl("txtName");14//TextBox ctrl = (TextBox)this.FindControl("UpdatePanel").FindControl("txtName");15string connectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";16string dataBase = @dotnet.itags.org."C:\Projects\Intnet Inc\ASP.NET\Experiment\App_Data\Enterprise.mdb";17using (OleDbConnection conn =new OleDbConnection(connectionString + dataBase))18 {1920string sqltext ="INSERT INTO NameTable(Name) VALUES(?)";21 OleDbCommand cmd =new OleDbCommand(sqltext, conn);22 cmd.Parameters.Add("@dotnet.itags.org.Name", OleDbType.VarChar, 255).Value = ctrl.Text;2324 conn.Open();25 cmd.ExecuteNonQuery();26 conn.Close();2728 BindGrid();29 }30 }3132protected void BindGrid()33 {34 GridView ctrl = (GridView)this.FindControl("UpdatePanel").FindControl("MyAccordion").FindControl("AccordionPane2").FindControl("GridView1");35//GridView ctrl = (GridView)this.FindControl("UpdatePanel").FindControl("GridView1");36string connectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";37string dataBase = @dotnet.itags.org."C:\Projects\Intnet Inc\ASP.NET\Experiment\App_Data\Enterprise.mdb";38using (OleDbConnection conn =new OleDbConnection(connectionString + dataBase))39 {40 DataSet ds =new DataSet();4142string sqltext ="SELECT * FROM NameTable";43 OleDbCommand cmd =new OleDbCommand(sqltext, conn);44 OleDbDataAdapter adapter =new OleDbDataAdapter(sqltext, conn);4546 adapter.Fill(ds,"Name");4748if (ctrl !=null)49 {50 ctrl.DataSource = ds.Tables["Name"].DefaultView;51 ctrl.DataBind();52 }53 }54 }55}

The problem is that when i submit my data to the database, the OnSubmit event handler is never excuted after the postback. When I click it again, then the OnSubmit event handler occurs during post back. However, the problem disappear when i remove line 6 and 7 from code behind. But I need it to load the data to be display for the first time. Pretty much when i run this app, when i click the submit button, the value inside the textbox will disappear... it seems it never got the data from the LoadPostBack phase of the life cycle, and also when i set up break point, the OnSubmit was never run. So I don't get it why I have to click 2nd time before OnSubmit actually work?

Hi,

The cause is that the clientID of the btnSubmit is different between the initial reuqest(ctl06_) and the subsequent partial request(ctl04_) .

So that the event handler can't be attached to it correctly.

I'm trying to find a workaround, or please share with us if you have got any.


Hi,jyu111

The Complete solution to your scenario is posted here..

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!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">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<ajaxToolkit:Accordion ID="MyAccordion" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40"
TransitionDuration="250" AutoSize="None" RequireOpenedPane="true" SuppressHeaderPostbacks="true">
<Panes>
<ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">
<Header>
<a href="http://links.10026.com/?link=" class="accordionLink">Insert New Task</a></Header>
<Content>
<asp:Label runat="server" ID="lblName" Text="Name"></asp:Label>
<asp:TextBox runat="server" ID="txtName"></asp:TextBox>
<asp:Button runat="server" ID="btnSubmit" Text="Submit!" />
</Content>
</ajaxToolkit:AccordionPane>
<ajaxToolkit:AccordionPane ID="AccordionPane2" runat="server">
<Header>
<a href="http://links.10026.com/?link=" class="accordionLink">Display Task</a></Header>
<Content>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true">
<EmptyDataTemplate>
<asp:Label runat="server" ID="lblBlank" Text="No Data!"></asp:Label>
</EmptyDataTemplate>
</asp:GridView>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Data.OleDb;
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 partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button btn = (Button)this.FindControl("UpdatePanel").FindControl("MyAccordion").FindControl("AccordionPane1").FindControl("btnSubmit");
btn.Click += new EventHandler(OnSubmit);
if (!Page.IsPostBack)
{
BindGrid();
}
}

protected void OnSubmit(object sender, EventArgs e)
{
TextBox ctrl = (TextBox)this.FindControl("UpdatePanel").FindControl("MyAccordion").FindControl("AccordionPane1").FindControl("txtName");
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
string dataBase = @."C:\Projects\Intnet Inc\ASP.NET\Experiment\App_Data\Enterprise.mdb";
using (OleDbConnection conn = new OleDbConnection(connectionString + dataBase))
{

string sqltext = "INSERT INTO NameTable(Name) VALUES(?)";
OleDbCommand cmd = new OleDbCommand(sqltext, conn);
cmd.Parameters.Add("@.Name", OleDbType.VarChar, 255).Value = ctrl.Text;

conn.Open();
cmd.ExecuteNonQuery();
conn.Close();

BindGrid();
ctrl.Text = "";
}
}

protected void BindGrid()
{
GridView ctrl = (GridView)this.FindControl("UpdatePanel").FindControl("MyAccordion").FindControl("AccordionPane2").FindControl("GridView1");
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
string dataBase = @."C:\Projects\Intnet Inc\ASP.NET\Experiment\App_Data\Enterprise.mdb";
using (OleDbConnection conn = new OleDbConnection(connectionString + dataBase))
{
DataSet ds = new DataSet();

string sqltext = "SELECT * FROM NameTable";
OleDbCommand cmd = new OleDbCommand(sqltext, conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(sqltext, conn);

adapter.Fill(ds, "Name");

if (ctrl != null)
{
ctrl.DataSource = ds.Tables["Name"].DefaultView;
ctrl.DataBind();
}
}
}
}

If this help you,don't forget mark it as a answer.Thanks!

Let me know if you need more info.


Hi,

I think my issue is pretty closely related to jyu111's problem but I'm not sure how to work the above solution into my specific situation.

I recently implemented an accordion in to my page to accomplish essentially what jyu111 was trying to do. I have a DetailsView control on my top pane for inserts and the bottom pane has a GridView. My setup is also different in that my accordion is inside one of four tab containers as well.

What's happening is, whenany link is clicked on either accordion pane (insert or cancel in the detailsview, or a column header for sorting or edit link in the gridview), the pane goes blank (the detailsview and gridview disappear). The only way I can bring them back is to either click on the tab header again, or refresh the whole page.

Here is the relevant code:

ASPX:

<form id="frmPersonnelAdmin" runat="Server" style="font-family: Verdana; font-size: 10px;"><div style="background-color: #FFFFBB; height: 800px; padding: 5px;"><asp:ScriptManager ID="ScriptManager1" runat="Server" /><div><ajaxToolkit:TabContainer ID="tabContPersonnelAdmin" runat="Server" CssClass="active_tab inactive_tab hover_tab"><ajaxToolkit:TabPanel ID="tabPayrollCompany" runat="Server" HeaderText="Payroll Company"><ContentTemplate><asp:UpdatePanel runat="server"><ContentTemplate><ajaxToolkit:Accordion ID="PersTypeAccordion" runat="server" SelectedIndex="1" RequireOpenedPane="True"SuppressHeaderPostbacks="False" FadeTransitions="True" HeaderCssClass="accordionHeader"ContentCssClass="accordionContent"><Panes><ajaxToolkit:AccordionPane runat="server" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent"><Header><asp:Label ID="lblInsertPersonnelTypeDetailsView" runat="Server" Text="Insert a new personnel type."Font-Bold="True" Height="30px"></asp:Label></Header><Content><asp:DetailsView ID="dvPersonnelTypeInsert" runat="server" AutoGenerateRows="False"InsertRowStyle-Font-Size="10px" DataKeyNames="PersonnelTypeID" DefaultMode="Insert"DataSourceID="SqlDataSourceDvInsertPersonnelType" BorderWidth="0px" BorderStyle="None"><Fields><asp:BoundField DataField="Description" HeaderText="Description" ControlStyle-Font-Size="10px" /><asp:TemplateField HeaderText="Personnel Category"><InsertItemTemplate><asp:DropDownList ID="ddlInsertPersCat" runat="Server" DataValueField="PersonnelCategoryID"DataTextField="ShortName" DataSourceID="SqlDataSourcePersonnelCategory" Font-Size="10px"SelectedValue='<%# Bind("PersonnelCategoryID")%>'></asp:DropDownList></InsertItemTemplate><HeaderStyle Width="140px" /></asp:TemplateField><asp:BoundField DataField="Markup" HeaderText="Markup" ControlStyle-Font-Size="10px" /><asp:CommandField ShowInsertButton="True" /></Fields></asp:DetailsView><br /></Content></ajaxToolkit:AccordionPane><ajaxToolkit:AccordionPane runat="server"><Header><asp:Label ID="lblPersonnelType" runat="Server" Text="List of personnel types." Font-Bold="True"Height="30px"></asp:Label></Header><Content><asp:GridView ID="gvPersonnelType" runat="server" AllowPaging="True" PageSize="20"AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="PersonnelTypeID"DataSourceID="SqlDataSourcePersonnelTypeGv" BorderWidth="0px" BorderStyle="None"RowStyle-Height="30px" RowStyle-BackColor="whitesmoke" AlternatingRowStyle-BackColor="#FFFFBB"PagerStyle-HorizontalAlign="Center" PagerStyle-BackColor="#CCCC99" HeaderStyle-BackColor="#CCCC99"><Columns><asp:CommandField ShowDeleteButton="True" ShowEditButton="True"><ControlStyle Width="50px" /></asp:CommandField><asp:TemplateField HeaderText="Labor Force Type" HeaderStyle-HorizontalAlign="center"HeaderStyle-Width="110px" SortExpression="LaborForceTypeID"><ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("LaborForceType")%>'></asp:Label></ItemTemplate><EditItemTemplate><asp:DropDownList ID="ddlEditLaborForceType" runat="server" DataValueField="LaborForceTypeID"DataTextField="DisplayName" DataSourceID="SqlDataSourceLaborForceType" Font-Size="10px"SelectedValue='<%# Bind("LaborForceTypeID")%>'></asp:DropDownList></EditItemTemplate><HeaderStyle Width="80px" /></asp:TemplateField><asp:BoundField DataField="Rebill" HeaderText="Rebill" SortExpression="Rebill" DataFormatString="{0:c}"HtmlEncode="False"><ControlStyle Font-Size="10px" Width="50px" /><HeaderStyle HorizontalAlign="Center" Width="60px" /></asp:BoundField><asp:BoundField DataField="Markup" HeaderText="Markup" SortExpression="Markup"><ControlStyle Font-Size="10px" Width="50px" /><HeaderStyle HorizontalAlign="Center" Width="60px" /></asp:BoundField></Columns><RowStyle BackColor="WhiteSmoke" Height="20px" /><PagerStyle BackColor="#CCCC99" HorizontalAlign="Center" /><HeaderStyle BackColor="#CCCC99" /><AlternatingRowStyle BackColor="#FFFFBB" /></asp:GridView><br /><br /><%-- --%></Content></ajaxToolkit:AccordionPane></Panes></ajaxToolkit:Accordion></ContentTemplate></asp:UpdatePanel></ContentTemplate></ajaxToolkit:TabPanel><ajaxToolkit:TabPanel ID="tabPersonnelCategory" runat="Server" HeaderText="Personnel Categories"><ContentTemplate>Anothertab</ContentTemplate></ajaxToolkit:TabPanel><ajaxToolkit:TabPanel ID="tabPersonnel" runat="Server" HeaderText="Personnel"><ContentTemplate><asp:UpdatePanel ID="updPnlPersonnel" runat="Server"><ContentTemplate>Another tab</ContentTemplate></asp:UpdatePanel></ContentTemplate></ajaxToolkit:TabPanel></ajaxToolkit:TabContainer></div></div></form>

And a couple of code-behind lines that are relevant to the controls in the accordion/tab in question:

Protected Sub dvPersonnelTypeInsert_ItemInserted(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.DetailsViewInsertedEventArgs)Handles dvPersonnelTypeInsert.ItemInserted'Commit detailsview insertgvPersonnelType.DataBind()End SubProtected Sub tabContPersonnelAdmin_ActiveTabChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles tabContPersonnelAdmin.ActiveTabChangedgvPersonnelType.EditIndex = -1End Sub

It should be noted that the detailsview and gridview do successfully execute thier inserts and edits/deletes, respectively.

While I'm at it, I'm wondering if someone could tell me how to change the header background color and font attributes for the accordion control.

Thanks!


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command);

btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command); btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command); btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command); btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command); btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command);

btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?


This is the exact problem I am having, only my link buttons are in a repeater, this solution doesn't seem to work with or without the repeater, has anyone found a workaround for this?

Here's my code:

Repeater rptPhotos = (Repeater)accMorningShow.Panes[3].FindControl("rptPhotos");foreach (RepeaterItem itmin rptPhotos.Items)

{

LinkButton btn = (LinkButton)itm.FindControl("lnbChangeCategory");

btn.Command +=newCommandEventHandler(lnbChangeCategory_Command); btn.Click +=newEventHandler(lnbChangeCategory_Click);

//btn.ClientID = btn.ClientID.Replace("ctl05", "ctl07");

}


GridView andDetailsView controlsare not compatible with partial-page updates when their EnableSortingAndPagingCallbacks property is set totrue(The default isfalse) , and is therefore not supported inside anUpdatePanel control.


Hi,smcefee

Give me more info about your codes. I'll test it^^^

Thanks.


Dear Sir, that is the solution! I Thank you!

Sir, my next question would be what if my text box and button are wrap inside a user control and i put a user control into a accordion pane? Because I tried using the same approach and it didn't work with user control.

Say I use a user control like: <test:user runat="server" id="UserControl" />

So something like:

Button btn = (Button)this.FindControl("UpdatePanel").FindControl("MyAccordion").FindControl("AccordionPane1").FindControl("UserControl").FindControl("btnSubmit");

it doesnt' work for my side... or I am making a typo mistake or something? But definately the code above works for the case if the "insert form" is inside the accordion pane.

Sir, can you explain why I cannot use a simple OnClick on the design but have to use findcontrol and set up event handling from code behind?