473,411 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

ASP Cant Find my Textbox Control


The code below cannot locate the Textbox "tbDuration" in my ASP.NET 2.0 page.

<Ajax.AjaxMethod()> _
Public Function calcTimeSpan(ByVal StartTime As String, ByVal EndTime As String) As String
Dim dblTimeSpan As Double
Dim RtnVal As String
Dim tb As TextBox

Try
If StartTime.Length < 1 Or EndTime.Length < 1 Then
Return ""
Else
dblTimeSpan = DateAndTime.DateDiff(DateInterval.Minute, CDate(StartTime), CDate(EndTime))

RtnVal = Format(dblTimeSpan / 60, "###0.0")
tb = Me.FindControl("tbDuration")
If Not tb Is Nothing Then tb.Text = RtnVal

Return RtnVal

End If

Catch ex As Exception
Return ""
End Try

End Function

As you can see, this is an AJAX function, and I am not at all familiar with AJAX (I didn't write this, but have been
charged with maintaining it).

As you can see, the code is pretty simple, just date manipulation, which is working - I can pass input values into the
codeblock and the calc occurs, so RtnVal has a value (eg: 2.0, 3.2, etc)

This project does use MasterPages, and if I ViewSource the tb is referenced as such:

ctl00_ContentPlaceHolder1_tbDuration

I've tried that, but the code errors out as well. If I remove the Me.FindControl and try to set the value directly,
without using FindControl:

Me.tbDuration.Text = RtnVal

then VS errors and I get a System.NullReferenceException telling me there is no Object referenced (which I assume means
it can't find tbDuration).

The textbox does exist, and Intellisense shows it.
Jun 8 '06 #1
2 1956
Hello Scott,

Thank you for posting in the ASPNET newsgroup.

From your description, I understand you're encountering some problem when
developing an ASP.NET web page that use some AJAX components, correct?

Based on my research, the AJAX component you're using is a 3rd party AJAX
framework mentioned below:

http://msdn.microsoft.com/library/en...edAjax.asp?fra
me=true

And I've also checked its workspace and the document, it seems that this
AJAX framework is using a custom httphandler to processing those ajax
callback from cilent-side script to server. And this custom httphandler(not
the original ASP.NET page's page handler) will help locate the certain ajax
method from the certain page class and call it. Therefore, as for such AJAX
method, it can not access the original ASP.NET page's page model or control
structure(they're not populated in the AJAX httphandler). Actually, such
AJAX method is used to perform some helper functions(such as server-side
calculation , or accesing some server-side database...). As for UI related
manipulation in AJAX environment, it is better to do some at client-side
directly on those cilent-side html elements through scripts.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 9 '06 #2
Hi Scott,

How are you doing in this issue, have you got any progress or does the
information in my last reply helps you a little? If there is anything else
we can help, please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edward | last post by:
hi, everyone, my Page_Load fill tblProducts with some TextBox. <form runat="server"> <asp:Table id="tblProducts" runat="server"></asp:Table> <hr> <asp:Button id="Button1"...
3
by: Chumley the Walrus | last post by:
I have a textbox control that represents a username in a password scheme, and I'm trying to turn the ID of the textbox control (the id = lgname ) into a session object. Doing lgname.text =...
2
by: Josh | last post by:
Hi Guys, I have been stuck on this problem for several days now, i have a set of nested datagrids. Inside the second datagrid i have a dropdown list, a textbox and a label. I want the textbox...
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
9
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see)...
4
by: Samy | last post by:
Hi There, I have a user control with a textbox and a button which when clicked opens a calendar control(calendar.aspx page). When I select a date from the calendar control, the date is supposed to...
5
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example,...
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
i have a master page and aseries of controls labeled fn1, fn2, fn3 , ... i want ot loop and use find control but i'm finding them. i'm using the following w/o luck ContentPlaceHolder cph =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.