Showing posts with label exception. Show all posts
Showing posts with label exception. Show all posts

Wednesday, March 28, 2012

ASP.NET Ajax Probelm

has anyone else tried viewing a page that has an updatepanel in different browsers like Opera. It doesn't work I get the following exception

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

might be something that the team wants to look into. I dont' have a probelm with firefox or netscape

hello.

if i'm not wrong, opera isn't fully supported yet (though i'm really hoping that it is when the release version gets out)

Saturday, March 24, 2012

asp label inside an accordion content

with the code behind i can not access the asp label in my accordion i get an error that says

Exception Details:System.NullReferenceException: Object reference not set to an instance of an object

my accordion looks like this :

<cc1:Accordion ID="GuestAccordian" runat="server" SelectedIndex="0"
FadeTransitions="True" FramesPerSecond="40" TransitionDuration="250" AutoSize="Fill" Visible="true" >
<Panes>
<cc1:AccordionPane ID="TodayCheckins" runat="server">
<Header><a href="http://links.10026.com/?link=" onclick="return false;">Today Check-ins</a></Header>
<Content>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPane ID="FutureCheckins" runat="server">
<Header><a href="http://links.10026.com/?link=" onclick="return false;">Future Check-ins</a></Header>
<Content>adfadsf</Content>
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>

my code behind is this :

string TodayCheckin = "";
using (SqlConnection conn = new SqlConnection(connString))
using (SqlCommand cmd = new SqlCommand(sql_stmt, conn))
{
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();

while (reader.Read())
{
TodayCheckin += reader.GetString(1);
}
conn.Close();
}
Label1.Text = TodayCheckin;

if I move the label out of the accordion it works fine, any ideas would be greatly appreciated.


try,

Label lbl = (Label) TodayCheckins.FindControl("Label1");
if(lbl != null) { lbl.Text = TodayCheckin; }

Wednesday, March 21, 2012

ask a question: an exception about tabcontainer

these sample code throwed an exception :

Specified argument was out of the range of valid values.
Parameter name: value

1TabPanel tp =new TabPanel();2tp.HeaderText = tableName;3string cmdText =string.Format("SELECT * FROM {0}", tableName);4MySqlCommand cmd =new MySqlCommand(cmdText, conn);5MySqlDataReader dr = cmd.ExecuteReader();6GridView gv =new GridView();7while (dr.Read())8{9 gv.DataSource = dr;10}11gv.DataBind();12tp.ContentTemplate.InstantiateIn(gv);13tabPanels.Add(tp);

How can i add tabpanels into a tabcontainer ??

Hi Franky,

Please use tp.Controls.Add(gv) instead of tp.ContentTemplate.InstantiateIn(gv); Here is the whole sample.

Aspx

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

<!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">
</asp:ScriptManager>
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server">
</ajaxToolkit:TabContainer>
</form>
</body>
</html>


C# code.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using AjaxControlToolkit;

public partial class Tab_Dynamically : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TabPanel tp = new TabPanel();
tp.HeaderText ="111";
List<string> myList = new List<string>();
myList.Add("11111");
myList.Add("22222");
myList.Add("33333");
GridView gv = new GridView();
gv.DataSource = myList;
gv.DataBind();
tp.Controls.Add(gv);

TabContainer1.Tabs.Add(tp);
TabContainer1.ActiveTabIndex = 0;
}

}

For more about InstantiateIn, please visithere.

I hope this help.

Best regards,

Jonathan