Mobile Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreMobile Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 13th, 2007, 03:49 AM
aruna gottimukk aruna gottimukk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 14 aruna gottimukk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 20 m 14 sec
Reputation Power: 0
Asp.net Mobile controls + NullReference Exception

Hi,

I am defining DeviceSpecific region in a ObjectList and trying to have header for each paginated page, header contains two labels whose text will set be after the results from the database like total number of records. When I try to execute the following code I am getting Object reference nullexception. I couldnt understand, could anyone please tell me, why I am getting that. Here is my code for aspx and code behind file.


<mobile:Form Runat=server ID="form" Paginate=True>
<mobile:ObjectList ID="rptPublications" Runat="server" OnPreRender="rptChecking_PreRender">
<DeviceSpecific ID="dspChkAcct" Runat="server">
<Choice>
<HeaderTemplate>
<mobile:Label ID="hitResults" Runat=server Font-Bold=True Font-Size=Normal StyleReference=title Text=""></mobile:Label>
<mobile:Label ID="pageIndex" Runat=server Font-Size=Small Text=""></mobile:Label>
</HeaderTemplate>
<ItemTemplate>
<mobile:Link ID="aViewTopic" Runat="server" Font-Size=Small NavigateUrl="" BreakAfter=True/>
<mobile:Label ID="tpcDetails1" Runat=server Font-Size=Small BreakAfter=True></mobile:Label>
<mobile:Label ID="tpcDetails2" Runat=server Font-Size=Small BreakAfter=True></mobile:Label>
</ItemTemplate>
<SeparatorTemplate><br /></SeparatorTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList> </mobile:Form>

Code Behind file



protected void rptChecking_PreRender(object sender, EventArgs e)
{

pageCount = form.PageCount.ToString();
((System.Web.UI.MobileControls.Label)rptPublications.Controls[0].FindControl("hitResults")).Text = "Search results for - " + searchKey + " (" + rptPublications.Items.Count + ")";
((System.Web.UI.MobileControls.Label)rptPublications.Controls[1].FindControl("pageIndex")).Text = "Showing Page" + currentPage + " of " + pageCount + ", Total Records: " + results.ChildNodes.Count;


foreach (ObjectListItem item in rptPublications.Items)
{

XmlNode node = (XmlNode)item.DataItem;
if (node != null)
{
Label pubTitle = (Label)item.FindControl("pubTitle");
Link aViewTopic = (Link)item.FindControl("aViewTopic");
Label tpcDeatils1 = (Label)item.FindControl("tpcDetails1");
Label tpcDeatils2 = (Label)item.FindControl("tpcDetails2");

string pubId = node.Attributes["PubId"].Value;
string title = node.Attributes["Title"].Value;
string topicHeading = node.SelectNodes("//TopicHeading").Item(item.Index).InnerText;
string topicID = node.SelectNodes("//TopicID").Item(item.Index).InnerText;
string topicType = node.SelectNodes("//TopicType").Item(item.Index).InnerText;
string author = node.SelectNodes("//Author").Item(item.Index).InnerText;
string views = node.SelectNodes("//NoOfViews").Item(item.Index).InnerText;
string comment = node.SelectNodes("//NoOfComments").Item(item.Index).InnerText;
string mDate = node.SelectNodes("//ModifiedDate").Item(item.Index).InnerText;

string topicLink = "/HNMobileApp/topic.aspx?tid=" + topicID;
aViewTopic.Text = topicHeading;
aViewTopic.NavigateUrl = topicLink;
tpcDeatils1.Text = "Comments: " + comment + " | " + "Views: " + views;
tpcDeatils2.Text = "By: " + author + " on " + mDate;

}
}

}



Thanks

Aruna.G

Reply With Quote
  #2  
Old November 13th, 2007, 04:08 AM
prcAdap's Avatar
prcAdap prcAdap is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2005
Location: Tír na nÓg
Posts: 1,147 prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 7 h 50 sec
Reputation Power: 172
Do you really need to ask twice?

If you debug line-by-line you will find the problem.
You have a variable somewhere you are trying to use before the variable has been populated.
If you debug, the application will crash on the line that is causing you the problem.
Give that a blast first and come back and let us know which line it is.

Reply With Quote
  #3  
Old November 13th, 2007, 04:13 AM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,773 jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Weeks 6 Days 7 h 23 sec
Reputation Power: 1632
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
Please use [asp]asp tags[/asp] or similar to highlight your code.
__________________
Cheers,

Jamie


# skiFFie | Home of the 'accessibility module' for Drupal
# Jamie Burns [me] Accessibility Module [drupal]
# guidelines | search | wap resources | not getting help | fold to cure


__________________

Let the might of your compassion arise to bring a quick end
to the flowing stream of the blood and tears .....
Please hear my anguished words of truth.



__________________

Reply With Quote
  #4  
Old November 13th, 2007, 04:29 AM
aruna gottimukk aruna gottimukk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 14 aruna gottimukk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 20 m 14 sec
Reputation Power: 0
Asp.net Mobile controls + NullReference Exception

Its very urgent for me. So I posted in two forums. For debugging I am completly using asp.net mobile control forms so I couldnot debug my code I can only run my code. I coded in ascx form and copied to aspx page and running my application in aspx page. If you have any idea how to debug this Please tell me.

Quote:
Originally Posted by prcAdap
Do you really need to ask twice?

If you debug line-by-line you will find the problem.
You have a variable somewhere you are trying to use before the variable has been populated.
If you debug, the application will crash on the line that is causing you the problem.
Give that a blast first and come back and let us know which line it is.

Reply With Quote
  #5  
Old November 13th, 2007, 05:36 AM
prcAdap's Avatar
prcAdap prcAdap is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2005
Location: Tír na nÓg
Posts: 1,147 prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 7 h 50 sec
Reputation Power: 172
Quote:
Originally Posted by aruna gottimukk
I coded in ascx form and copied to aspx page and running my application in aspx page.
OK, you are using Visual Studio?! Which version?
In 2005, goto the Debug menu,
Select 'Attach To Process...',
Find 'aspnet_wp.exe' in the process list - select it and click 'Attach'.

That's one way, another is to click the green 'play' button.

Reply With Quote
  #6  
Old November 14th, 2007, 05:31 AM
aruna gottimukk aruna gottimukk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 14 aruna gottimukk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 20 m 14 sec
Reputation Power: 0
Asp.net Mobile controls + NullReference Exception

Hi,
I have successfully debug my code, I found that the mobile control inside the Choice cannot be found. Even I tried with the simple code like below and its also not finding my mobile control. Do anyone have idea?

<mobile:Form id="external_link" runat="server">
<mobile:ObjectList ID="externalPublications" Runat=server OnItemDataBind="externalPublications_ItemDataBind">
<DeviceSpecific ID="dspChkPub" Runat=server>
<Choice>
<ItemTemplate>
<mobile:Label ID="topictitle" Runat=server />
</ItemTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>
</mobile:Form>

Thanks,
Aruna.G

Reply With Quote
  #7  
Old November 14th, 2007, 06:03 AM
prcAdap's Avatar
prcAdap prcAdap is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2005
Location: Tír na nÓg
Posts: 1,147 prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level)prcAdap User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 7 h 50 sec
Reputation Power: 172
Hi again,

I haven't done any mobile application development myself, but read this from MS about DeviceSpecific Class.
It looks like a pretty good example and uses the FindControl method.
Give that a blast.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreMobile Programming > Asp.net Mobile controls + NullReference Exception


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway