Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all 5678 articles
Browse latest View live

Update Panel throwing an error.

$
0
0

I want to update a panel that contains image control. I want that only this portion should be updated instead of whole page so i am using AJAX.

I am using this code in my aspx file:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server"><Triggers><asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" /><asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" /></Triggers><ContentTemplate><asp:Panel ID="Panel1" runat="server" Height="602px" Width="1087px"><asp:Button ID="Button1" runat="server" Text="Remove" onclick="Button1_Click"
                        Width="70px" /><br /><asp:TextBox ID="TextBox1" runat="server" ReadOnly="True" Width="704px"></asp:TextBox><br /><asp:Image ID="Image1" runat="server" Height="488px" Width="992px" /><br /><br /><asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="&lt;&lt;"
                        Width="70px" Height="25px" /><asp:Button ID="Button3" runat="server" Height="25px" onclick="Button3_Click"
                        Text="&gt;&gt;" Width="70px" /></asp:Panel></ContentTemplate></asp:UpdatePanel>

My image control and textbox control are changed dynamically from c# code as:

protected void Button2_Click(object sender, EventArgs e)
    {
          Image1.ImageUrl = li[c].Substring(61);
          TextBox1.Text = li[c].Substring(67 + len + 8);
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
       
          Image1.ImageUrl = li[c].Substring(61);
          TextBox1.Text = li[c].Substring(67 + len + 8);
    }

where c is some counter variable.

I am getting an error stating "JavaScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed."

How can I get rid of this error and load images correctly ?



Client side web service

$
0
0

Hi, I havewebservice added in Scripmanager Scriptreference tag

  <asp:ScriptManager ID="ScriptManager1" runat="server">
          <Services>
            <asp:ServiceReference Path="~/MyService.asmx" />
        </Services>
    </asp:ScriptManager>

And used the methods of webservice at client side.

I have usedthe following in web.config file to open the application in multiple tabs with different session id:

 <sessionState mode="InProc" timeout="20" cookieless="UseUri">
    </sessionState>

Problem:

I call my page i get error webservice "InvalidException" Object reference not set to the instance of the object.

Please anyone can help..would be greatly appreciated..Thanks :(

Value caption in Graph

$
0
0

Hi,

i am using ajaxtoolkit Linechart and it has make my life easy. The line chart is showing the values along with the graph in the graph area. for example if the value is 5 then it is drawing a line to 5 as well as showing the text 5 along with the line.  I just want to know the way how can i hide that caption. I mean the graph just draw the line but do not show the text along with the line. Example is given below.

line chart

Update Panel Javascript Call from Code Behind

$
0
0

Hello Experts,

   I have question, i am loading javascript from Code behind.

  But here,when using update panel then code behind javascript is not calling.

  How to Accomplish this,Help me with this.

Here is the following code:

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

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %><!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 id="Head1" runat="server"><title>Untitled Page</title></head><body><form id="form1" runat="server"><asp:ScriptManager EnablePartialRendering="true"
 ID="ScriptManager1" runat="server"></asp:ScriptManager><div><asp:UpdatePanel ID="UpdatePanel1" runat="server"
 UpdateMode="Conditional"><ContentTemplate><asp:Label ID="Label1" runat="server" /><br /><asp:Button ID="Button1" runat="server"
 Text="Update Both Panels" OnClick="Button1_Click" /><asp:Button ID="Button2" runat="server"
 Text="Update This Panel" OnClick="Button2_Click" /><asp:CheckBox ID="cbDate" runat="server"
 Text="Include Date" AutoPostBack="false"
 OnCheckedChanged="cbDate_CheckedChanged" /></ContentTemplate></asp:UpdatePanel><asp:UpdatePanel ID="UpdatePanel2" runat="server"
 UpdateMode="Conditional"><ContentTemplate><asp:Label ID="Label2" runat="server"
 ForeColor="red" /></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="Button1"
 EventName="Click" /><asp:AsyncPostBackTrigger ControlID="ddlColor"
 EventName="SelectedIndexChanged" /></Triggers></asp:UpdatePanel><asp:DropDownList ID="ddlColor" runat="server"
 AutoPostBack="true"
 OnSelectedIndexChanged="ddlColor_SelectedIndexChanged"><asp:ListItem Selected="true" Value="Red" /><asp:ListItem Value="Blue" /><asp:ListItem Value="Green" /></asp:DropDownList><asp:Button ID="btnScript" runat="server"  Text="Call JavaScript" OnClick="btnScript_Click"/></div></form></body></html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

public partial class Default6 : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnScript_Click(object sender, EventArgs e)
    {
        System.Text.StringBuilder sbScript = new System.Text.StringBuilder("");
        sbScript.Append("<script language='javascript'>");
        sbScript.Append("function Click() {");
        sbScript.Append("alert('test');");
        sbScript.Append("}");
        sbScript.Append("</script>");

        ScriptManager.RegisterStartupScript(this, GetType(), "ClientScript", "<script>" + sbScript.ToString() + "</script>", true);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (cbDate.Checked)
        {
            Label1.Text = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
            Label2.Text = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
        }
        else
        {
            Label1.Text = DateTime.Now.ToLongTimeString();
            Label2.Text = DateTime.Now.ToLongTimeString();
        }

       

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (cbDate.Checked)
        {
            Label1.Text = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
        }
        else
        {
            Label1.Text = DateTime.Now.ToLongTimeString();
        }
    }
    protected void cbDate_CheckedChanged(object sender, EventArgs e)
    {
        cbDate.Font.Bold = cbDate.Checked;
    }
    protected void ddlColor_SelectedIndexChanged(object sender, EventArgs e)
    {
        Color c = Color.FromName(ddlColor.SelectedValue);
        Label2.ForeColor = c;
    }
}



implement updatepanel,scriptmanager, asyncpostbacktriggers in my asp.net 4.0 web appln

$
0
0

hi,

am not using ajacontroltoolkit.

but wanna  implement ajax- scriptmanager, updatepanel asyncpostbacktriggers  etc in my aspx pages.

1)           how to implement these?

2)            also wanna implment in a  usercontrol also.

instead of putting scriptmanager control in all the  aspx pages, is it ok, that i can insert this tag in the master page, once and it will be applied everywhere?

in that case (3), why its failing to implement it in a user control?

and

(4) when i implement javascript validation in my aspx page, it throws error when other team members uses redfieldvalidator for form validation in their aspx pages?  does that mean that javascript/jquery validation  doesnt go hand-in-hand with ajax implmentation?

(5) am having  simple form with few txtboxes, dropdown with a submit button-- how can i implement ajax in this form

any help is appreciated..

 

Save AJAX Editor content as HTML file

$
0
0

Hi All,

How to save Ajax Editor content as an HTML file to a disk?  Please help.

Let's say I have an Ajax Editor which allows user to type or paste in long message or writting.  Once he clicks on "submit" button, an HTML file will be created and save to a disk.  I am working on asp.net 3.5, ajax version 3.5 (from codeplex, work well).

Thank you for your help.

asp_net

Could not load file or assembly 'vjslib, Version=2.0.0.0 .. .\TemplateVSI\TemplateVSI.csproj

$
0
0

hi ı do http://www.asp.net/learn/ajax-videos/video-76.aspx on this video. but ı have to encounter this error
:
Error 1 Could not load file or assembly 'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.  C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\TemplateVSI\TemplateVSI.csproj 57 5 TemplateVSI


AjaxFileUpload: how to customize blob name when uploading to Azure?

$
0
0

The update of AjaxFileUpload to support uploading directly to Azure blob storage is very cool.  However, it looks like the uploaded blob name is always the client file name, relative to the container name specified in the AzureContainerName property.  It would be nice if we could set the blob name to something else, so that we could use the virtual blob directory feature or rename to avoid collisions with duplicate names.  Azure doesn't support renaming of an existing blob, so this would have to be done before the upload starts.  Short of building a custom version of the Toolkit, I can't tell if this can be accomplished using the existing server-side or client-side event callbacks.  Any suggestions?


Telerik RadControls for ASP.NET Ajax Version - 2009.2.701.20

$
0
0

Hi All,

We are using Telerik RadControls for ASP.NET Ajax Version - 2009.2.70 in VS2005.
Now we want to migrate VS2012.

Question

Will Telerik RadControls for ASP.NET Ajax Version - 2009.2.70 work for VS 2012 and IE 10 Browser?

I tried to migrate the source code,Rad Controls are working fine in Chrome and Firefox but getting some scripting errors in IE 10,

I want to know whether  Rad Controls Version 2009.2.70 will work for VS 2012 and IE 10 Browser or not?

Thank You
Varma

Parsing error

$
0
0

I am using updatepanel on page. Button is in AsyncPostBackTrigger.

I got error :

Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near ' <!DOCTYPE html PUB'.


If I use butting in PostBackTrigger then it works fine. But because of some conditions on page, I need to use button AsyncPostBackTrigger only. So is there anyother solution available ???


partial refresh using update panel working with c# code but not with VB

$
0
0

below given VB.net code , not working but if write the same thing in C# it works 

<div>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<asp:Label ID="Label1" runat="Server"></asp:Label>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="Server">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></asp:Label>
<br />
<br />
<asp:Button ID="Button2" runat="server" Text="Click Me Again" OnClick="Button2_Click"/>
</ContentTemplate>
</asp:UpdatePanel>
</div>

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Label2.Text = DateTime.Now.ToString()
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = DateTime.Now.ToString()

End Sub

FileUpload Inside of Gridview Which Is Inside of UpdatePanel

$
0
0

I have read a ton of articles on how to fix the issue of having a fileupload inside of an updatepanel.

Basically the reasoning is that having the fileupload control inside of an update panel is a security issue.  And to get around it

you need to wrap a triggers <TRIGGERS> tag with a button control to do a post back for the file upload control.  However,

this does not work for me because I have a gridview inside of my update panel.  I tried to put a triggers tag inside of the update panel

but it complained that it could not find a control with ID btnUpload.  I think it is because the button is inside of my gridview which is inside of my update panel.

My issue is basically that fileupload control returns false, and I read that it is because it needs to post back.  

Can anyone help me out?

Here is my gridview code:

 <pre>

 

<asp:UpdatePanelID="myPanel"runat="server">

 

<ContentTemplate>

 

<asp:GridViewCellPadding="3"Font-Size="X-Small"DataKeyNames="ID"Width="100%"GridLines="both"AlternatingRowStyle-BackColor="#F0F8FF"BackColor="#E8E8E8"HeaderStyle-BackColor="#377CB1"ID="gvLineItems"runat="server"AllowSorting="True"AutoGenerateColumns="False"OnSelectedIndexChanged="gvLineItems_SelectedIndexChanged">

 

<Columns>

 

 

<asp:TemplateFieldHeaderText="ID"SortExpression="ID"Visible="False">

 

<ItemTemplate>

 

<asp:LabelID="lblExpenseReportLineItemID"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:Label>

 

</ItemTemplate>

 

</asp:TemplateField>

 

 

<asp:TemplateField>

 

<HeaderTemplate>

 

<asp:CheckBoxID="HeaderLevelCheckBox"runat="server"/>

 

</HeaderTemplate>

 

<ItemTemplate>

 

<asp:CheckBoxID="chkSelector"runat="server"onclick="ChangeRowColor(this)"/>

 

</ItemTemplate>

 

<ItemStyleHorizontalAlign="Center"Width="1%"/>

 

<HeaderStyleHorizontalAlign="Center"/>

 

 

 

</asp:TemplateField><asp:TemplateField>

 

<ItemTemplate>

 

<asp:ImageButtonID="ibAddLineItem"runat="server"ImageUrl="images/InsertRow.gif"CommandName="Insert"ToolTip="Insert new row"/>

 

</ItemTemplate>

 

<ItemStyleWidth="1%"/>

 

</asp:TemplateField>

 

 

<asp:TemplateField>

 

<ItemTemplate>

 

 

<asp:ImageButtonID="ibDelete"runat="server"CommandName="DeleteRow"ImageUrl="images/d.gif"

 

ToolTip="Delete Line Item?"/>

 

 

</ItemTemplate>

 

</asp:TemplateField>

 

 

<asp:TemplateFieldHeaderText="Date"SortExpression="Date">

 

<ItemTemplate>

 

<ajaxToolkit:CalendarExtenderTargetControlID="txtLineItemDate"ID="CalendarExtender3"runat="server">

 

</ajaxToolkit:CalendarExtender>

 

<asp:TextBoxWidth="60px"ID="txtLineItemDate"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.LineItemDate") %>'>

 

</asp:TextBox>

 

</ItemTemplate>

 

<ItemStyleHorizontalAlign="Center"Width="10%"/>

 

<HeaderStyleForeColor="White"HorizontalAlign="Center"Width="12%"/>

 

 

 

</asp:TemplateField><asp:TemplateFieldHeaderText="Reason"SortExpression="Reason">

 

<ItemTemplate>

 

<asp:DropDownListWidth="100px"ID="ddlExpenseTypes"DataSource='<%# GetExpenseTypes() %>'SelectedValue='<%# Bind("ExpenseReasonID") %>'DataTextField="ExpenseReasonID"DataValueField="ExpenseReasonID"runat="server"></asp:DropDownList>

 

</ItemTemplate>

 

<ItemStyleHorizontalAlign="Center"Width="50%"/>

 

 

 

</asp:TemplateField><asp:TemplateFieldHeaderText="Receipt"SortExpression="Date">

 

<ItemTemplate>

 

<asp:CheckBoxID="cbReceipt"runat="server"Checked='<%# DataBinder.Eval(Container, "DataItem.HasReceipt") %>'/>

 

</ItemTemplate>

 

<HeaderStyleForeColor="White"/>

 

<ItemStyleHorizontalAlign="Center"Width="1%"/>

 

 

 

</asp:TemplateField><asp:TemplateFieldHeaderText="Amount"SortExpression="Amount">

 

<ItemTemplate>

 

<asp:TextBoxWidth="40px"ID="txtAmount"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.AmountSpent") %>'/>

 

</ItemTemplate>

 

<ItemStyleWidth="1%"/>

 

</asp:TemplateField>

 

 

<asp:TemplateFieldHeaderText="Currency"SortExpression="Currency">

 

<ItemTemplate>

 

<asp:DropDownListID="ddlCurrency"OnSelectedIndexChanged="ddlCurrency_SelectedIndexChanged"runat="server"AutoPostBack="true"DataSource='<%# GetCurrency() %>'SelectedValue='<%# Bind("CountryID") %>'DataTextField="CountryID"DataValueField="CountryID"></asp:DropDownList>

 

</ItemTemplate>

 

<ItemStyleHorizontalAlign="Center"Width="50%"/>

 

 

 

</asp:TemplateField><asp:TemplateFieldHeaderText="Rate"SortExpression="Rate">

 

<ItemTemplate>

 

 

<asp:TextBoxWidth="40px"ID="txtRate"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.Rate") %>'/></ItemTemplate>

 

<ItemStyleWidth="1%"/>

 

</asp:TemplateField>

 

 

<asp:TemplateFieldHeaderText="USD"SortExpression="USD">

 

<ItemTemplate>

 

 

<asp:LabelID="lblUSD"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.AmountBackInUSD") %>'/></ItemTemplate>

 

<ItemStyleWidth="1%"/>

 

</asp:TemplateField>

 

 

<asp:TemplateFieldHeaderText="Desc."SortExpression="Desc.">

 

<ItemTemplate>

 

 

<asp:TextBoxWidth="100px"Font-Names="Arial"ID="txtExpenseReasonDescription"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.ExpenseReasonDescription") %>'/></ItemTemplate>

 

<ItemStyleWidth="1%"HorizontalAlign="Left"/>

 

</asp:TemplateField>

 

 

 

<asp:HyperLinkFieldHeaderText="Link"SortExpression="Link"DataNavigateUrlFields="AttachmentLink"DataNavigateUrlFormatString="{0}"

 

DataTextField="AttachmentLink"DataTextFormatString="Link"Target="_blank">

 

<ControlStyleForeColor="Navy"/>

 

<HeaderStyleForeColor="White"/>

 

</asp:HyperLinkField>

 

 

<asp:TemplateFieldHeaderText="Upload File?"SortExpression="ID">

 

<ItemTemplate>

 

<asp:FileUploadWidth="100px"ID="fuAttachment"runat="server"/>

 

<asp:ButtonID="btnUpload"runat="server"Text="Upload"/>

 

</ItemTemplate>

 

<HeaderStyleForeColor="White"/>

 

</asp:TemplateField>

 

</Columns>

 

<HeaderStyleBackColor="#377CB1"/>

 

<AlternatingRowStyleBackColor="AliceBlue"/>

 

</asp:GridView>

 

<divstyle="width:100%">

 

<asp:LabelID="lblMessage2"runat="server"></asp:Label>

 

</div>

 

<divstyle="width:100%; text-align:right;">

 

<tablewidth="100%"cellpadding="0"cellspacing="0">

 

<tr>

 

<tdclass="tableFields">

 

&nbsp;</td>

 

<td>

 

<asp:PanelID="pGridControls"runat="server"Width="100%"Visible="False">

 

<asp:LabelID="Label2"runat="server"Text="Any changes must be followed by a <u>save</u>!"BackColor="#FFFF80"Font-Bold="True"ForeColor="#377CB1"></asp:Label>

 

<asp:ImageButtonID="ibSaveGrid"runat="server"ImageUrl="images/smallSave.gif"ToolTip="Save / refresh changes?"CausesValidation="False"OnClick="ibSaveGrid_Click"/><asp:ImageButtonID="ibDeleteGrid"runat="server"ImageUrl="images/smallDelete.gif"ToolTip="Delete checked rows?"CausesValidation="False"OnClick="ibDeleteGrid_Click"/></asp:Panel>

 

</td>

 

</tr>

 

</table>

 

</div>

 

</ContentTemplate>

 

 

 

 

 

<Triggers><asp:PostBackTriggerControlID="btnUpload"/></Triggers></asp:UpdatePanel>

</pre>

Notice the triggers tag...when I load the page it automatically gives me an error saying btnUpload control not found!

 

AJAX AutoComplete asmx Web Script called locally and not on server

$
0
0

 have an ajax autocomplete code that I have working successfully on my computer running Visual Studio 2012. The code for the autocomplete is in an asmx file.

I have now deployed the code to my hosted webserver and now when you go to the page and enter in any data to the text box, nothing happens. There are no errors in the event viewer but nothing happens either.

See below for code.

Loosing focus after autopostback in Listview

$
0
0

I have a listview with 5 textboxes. In the first box I have a javascript that riggers the autopostback after 6 characters are entered. I need it to jump to the next textfield after that or just maintain focus, so that after they hit the tab button they will tab to the next field. I hope this isn't too vague.

How to show Zero values in ajax Animated Pie Chart control

$
0
0

I was made dynamically populate ASP.Net AJAX Control Toolkit Animated Pie Chart control from SQL Server Database it was working fine for me with more than zero data values and i was unable to show the values when all the data values are zero .

I want to show zero values also inPie Chart control how can i achive this ?



Error Using Update Panel and ImageButton

$
0
0

Hi, since i update IE9 to IE10, im getting this error: Javascript runtime error: sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format.

This happend if i use update panel, image button inside update panel and when i try to click the button, the server code never run and i cant debug the my code.

Any solutions or service packs for this?

Partial Page Postback makes custom color picker dissappear

$
0
0

Not sure where this question should go but the ajax partial page post back is was seems to be causing the issue.

I have written a custom color server control based off of the tool from

http://www.eyecon.ro/colorpicker/

Everything works great except the color picker dissappearch after the page does a partial page postback.

Ussually I could just add

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(BindEvents);

but in this case not sure were to go.

how to define customized css in htmleditor in ajax

$
0
0

when i am adding text in text box containing html editor its adding default font size and family ,line height and all

I want it to use customized css as i this text is coming from server  to website so it will be same everywhere

Specially font siz and font family and line height not working

Plz suggest

thnx

UpdatePanel + Panel with dynamic content + GridViews

$
0
0

Hi,

I have one 2 CheckBoxList and 1 RadioButtonList that, as they change, I render one or more GridViews based on these selections. The problem is that when the new tables are beeing rendered I'd still like to get some informations of the old one, but for some reason the Panel which I add the new Grids Control comes always empty to me, like I've never redered anything inside it. Probably I'm doing something wrong, but I'm havin a hard time figuring out. Here it is my aspx:

<asp:UpdatePanel ID="UpdatePanelGoals" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:Panel ID="PanelPeriods" runat="server" Visible="true"><h3>Per&iacute;odos</h3><asp:CheckBoxList ID="CheckBoxListPeriods" RepeatColumns="4" CellPadding="3"
                    AutoPostBack="true" runat="server"
                    OnSelectedIndexChanged="CheckBoxListPeriodModality_SelectedIndexChanged"></asp:CheckBoxList></asp:Panel><asp:Panel ID="PanelModalities" runat="server" Visible="true"><h3>Modalidades</h3><asp:CheckBoxList ID="CheckBoxListModalities" RepeatColumns="4" CellPadding="3"
                    AutoPostBack="true" runat="server"
                    OnSelectedIndexChanged="CheckBoxListPeriodModality_SelectedIndexChanged"></asp:CheckBoxList></asp:Panel><asp:Panel ID="PanelGoalsOptions" runat="server" Visible="true"><h3>Op&ccedil;&otilde;es</h3><asp:RadioButtonList ID="RadioButtonListGoalsOptions" RepeatColumns="4" CellPadding="3"
                   AutoPostBack="true" runat="server"
                   OnSelectedIndexChanged="CheckBoxListPeriodModality_SelectedIndexChanged"><asp:ListItem Value="1" Text="Option 1"></asp:ListItem><asp:ListItem Value="2" Text="Option 2"></asp:ListItem><asp:ListItem Value="3" Text="Option 3"></asp:ListItem></asp:RadioButtonList></asp:Panel><asp:Panel ID="PanelGoals" runat="server" Visible="true"><h3>Definir meta</h3><asp:Literal ID="LiteralGoals" runat="server"><div class="alert2">Info message.</div></asp:Literal><asp:Panel ID="PanelGridsPeriodsModalities" runat="server"></asp:Panel></asp:Panel></ContentTemplate></asp:UpdatePanel>

My CheckBoxLists are empty because I fill them later one the code.

All my grids are rendered on the PanelGridsPeriodsModalities, which in the beginning is empty. After I select at least one item on each CheckBoxList and the RadioButtonList the tables are rendered inside the CheckBoxListPeriodModality_SelectedIndexChanged function on codebehind...

Here is my CheckBoxListPeriodModality_SelectedIndexChanged function:

protected void CheckBoxListPeriodModality_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int numberPeriods = CheckBoxListPeriods.Items.Count;
                for (int i = 0; i < numberPeriods; i++)
                    if (CheckBoxListPeriods.Items[i].Selected)
                        listPeriods.Add(new ListPeriods(Convert.ToInt32(CheckBoxListPeriods.Items[i].Value), CheckBoxListPeriods.Items[i].Text));

                int numberModalities = CheckBoxListModalities.Items.Count;
                for (int i = 0; i < numberModalities; i++)
                    if (CheckBoxListModalities.Items[i].Selected)
                        listModalities.Add(new ListModalities(Convert.ToInt32(CheckBoxListModalities.Items[i].Value), CheckBoxListModalities.Items[i].Text));
            }
            catch (Exception ex) {}

            listPeriods.OrderBy(x => x.id);
            listModalities.OrderBy(x => x.id);

            this.renderTables();
        }

        private void renderTables()
        {
            if (listPeriods.Count() <= 0 || listModalities.Count() <= 0 || RadioButtonListGoalsOptions.SelectedValue == "")
            {
                PanelGridsPeriodsModalities.Controls.Clear();
                LiteralGoals.Visible = true;
                return;
            }

            try
            {
                List<GridView> gridsView = new List<GridView>();

                listModalities.ForEach(modality =>
                {
                    List<GridRow> rows = new List<GridRow>();
                    GridView modalityGrid = new GridView();

                    modalityGrid.UseAccessibleHeader = true;
                    modalityGrid.AutoGenerateColumns = false;
                    modalityGrid.ID = "GridViewModalityPeriod-" + modality.id;

                    listPeriods.ForEach(period =>
                    {
                        rows.Add(new GridRow(modality.id, modality.name, period.id, period.name, 
Realizado, Lata, Galao, Quartinho, "")); }); TemplateField tfModality = new TemplateField(); tfModality.ItemTemplate = new GridViewTemplateText(DataControlRowType.DataRow, "Modalidade"); tfModality.HeaderTemplate = new GridViewTemplateText(DataControlRowType.Header, "Modalidade"); modalityGrid.Columns.Add(tfModality); TemplateField tfPeriod = new TemplateField(); tfPeriod.ItemTemplate = new GridViewTemplateText(DataControlRowType.DataRow, "Período"); tfPeriod.HeaderTemplate = new GridViewTemplateText(DataControlRowType.Header, "Período"); modalityGrid.Columns.Add(tfPeriod); TemplateField tfRealizedYearBefore = new TemplateField(); tfRealizedYearBefore.ItemTemplate = new GridViewTemplateRealized(DataControlRowType.DataRow,
"Realizado ano anterior", Convert.ToInt32(RadioButtonListGoalsOptions.SelectedValue), "Last"); tfRealizedYearBefore.HeaderTemplate = new GridViewTemplateRealized(DataControlRowType.Header,
"Realizado ano anterior", Convert.ToInt32(RadioButtonListGoalsOptions.SelectedValue), "Last"); modalityGrid.Columns.Add(tfRealizedYearBefore); TemplateField tfRealizedYearAfter = new TemplateField(); tfRealizedYearAfter.ItemTemplate = new GridViewTemplateRealized(DataControlRowType.DataRow,
"Realizado ano atual", Convert.ToInt32(RadioButtonListGoalsOptions.SelectedValue), "Actual"); tfRealizedYearAfter.HeaderTemplate = new GridViewTemplateRealized(DataControlRowType.Header,
"Realizado ano atual", Convert.ToInt32(RadioButtonListGoalsOptions.SelectedValue), "Actual"); modalityGrid.Columns.Add(tfRealizedYearAfter); TemplateField tfMeta = new TemplateField(); tfMeta.ItemTemplate = new GridViewTemplateText(DataControlRowType.DataRow, "Meta"); tfMeta.HeaderTemplate = new GridViewTemplateText(DataControlRowType.Header, "Meta"); modalityGrid.Columns.Add(tfMeta); modalityGrid.DataSource = rows; modalityGrid.DataBind(); modalityGrid.Rows[0].Cells[0].Attributes.Add("rowspan", listPeriods.Count().ToString()); modalityGrid.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; modalityGrid.Rows[0].Cells[0].VerticalAlign = VerticalAlign.Middle; for (int i = 1; i < modalityGrid.Rows.Count; i++) modalityGrid.Rows[i].Cells[0].Visible = false; gridsView.Add(modalityGrid); }); PanelGridsPeriodsModalities.Controls.Clear(); gridsView.ForEach(gridView => PanelGridsPeriodsModalities.Controls.Add(gridView)); LiteralGoals.Visible = false; } catch (Exception ex) { } }

Every time I chage my selections its all good with generating the table and its fields, but my PanelGridsPeriodsModalities(Panel that holds my grids) is always empty, and i don't know how to get the older values.

Is there anything I'm doing wrong? Anything I could do to get it?

Thanks in advance.

Victor.

Any way to hide a control until a page postback?

$
0
0

Hey yall,

I've got an Ajax Accordian control. Is there any way I can hide the control until a page postback?

For example,

My page is intentionally left blank until data is summoned for several GridViews via a text box control.

I have one of the GridView, which contains a long list of data, that I have wrapped in an Accordion control. Of course, the GridView stays hidden until the data is summoned but the accordion is static. I would like to hide the accordion as well until the data for the GridView is summoned.

Thanks,

-Cody

Viewing all 5678 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>