function call inside aspx page for function in code behind not executing?


 I converted an .NET 1.1 web application to .NET 2.0 framework.

The original .NET 1.1 page runs fine.

The webpage has a datagrid, when a label control tries to be populated by a null value I get the following error:
Conversion from type 'DBNull' to type 'Date' is not valid.

the code on the aspx page:

<asp:Label id="Label1" runat="server">
        <%# AppDateFormat(DataBinder.Eval(Container, "DataItem.start_Date")) & " - " & AppDateFormat(DataBinder.Eval(Container, "DataItem.end_date"))  %>

 In the code beside page is :

Function AppDateFormat(ByVal value As Date) As String

If Not IsDBNull(value) ThenReturn Format(value, "dd-MMM-yyyy")


Return ""

End If

End Function

I break point the function, but when stepping through the code , i does'nt seem to break when it should, I think maybe it is'nt being executed after the .NET conversion.

Instead: I now have the following change to the aspx page: which works :

<%# iif(isdbnull(DataBinder.Eval(Container, "DataItem.start_Date"))," ",DataBinder.Eval(Container, "DataItem.start_Date")) & " - " & iif(isdbnull(DataBinder.Eval(Container, "DataItem.end_Date"))," ",DataBinder.Eval(Container, "DataItem.end_Date")) %>

Although I solved the problem in a round  about way: I would prefer to get the original function working and executing when it should.
This same situation occurs in dozens of locations throughout the webapp and would like to not have to fix it in all these locations like this.

 Please advise.



3/5/2009 4:00:29 PM 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 16

pass in an object to your function and then try to convert the object to a date.


Function AppDateFormat(ByVal value As Date) As String

as object) as String

Good Luck

3/5/2009 5:28:46 PM

Similar Artilces:

Setting width for .net controls in code(.aspx) page using function call in code behind..
Hi,  Currently I am trying to set the width of the Table as follows. <asp:Table width="<%=GetWidth()%>" >   and code behind protected Unit GetWidth() { return Unit.Percentage(50); }     It's not working. I know that it works if I set the width complete on some page event(like page_load) of code behind....   Is there a way to maintain the same syntax like calling code behind function in design page...i.e. calling function of .aspx.cs in .aspx page and assign the width as shown above.   Thanks and regards, Giridhar...

How to call a code behind function in user control from parent aspx page
Hi folks: Beginner needs help. I have a web user control and has a simple function "callme()" in it. This user control is added to an aspx page.How can I call  function "callme()" when a button is clicked in the aspx page?Any help  is greatly appreciated! Thanks!        Web hosting coupons Make the CallMe method public and in your ASPX button click event call <usercontroldid>.CallMe(). Hope that helpsThanksGaneshIf you find my reply help you Mark it Answered. just for html view of the aspx page. See th...

Calling code-behind functions from aspx page
Hi, I’ve been struggling for the last few hours over something I think should be very basic: Q: How do I call a C# function in my codebehind file from my .aspx file? Please refer to the code highlighted in yellow below. Is this the correct way to call a codebehind function? I keep getting an error "Literal content ('</asp:MenuItem>') is not allowed within a 'System.Web.UI.WebControls.MenuItemCollection'" Here’s a snippet in my .aspx file: <asp:Menu ID="Menu1" runat="server">    <S...

Call codebehind method from aspx page OR call javascript function of usercontrol control from page
Hi, I have a page which contains a user control.  When a user clicks on a submit button, I'd like to detect when elements in the user control have changed and popup a message box if changes have been detected to confirm if the user wants to save the changes. Obviously the message box is executed using javascript.  But I'd really like to be able to call a method in the code behind of the page which queries the user control if it has changed.  Is there a way of calling the code behind method from within a javascript function? Otherwise, if I make all the functions execut...

calling javascript function on aspx page from somefunction in code behind
can i call a javascript function on aspx page from somefunction in code behind like say CodeBehindFunction() { x =a; ............. ................ ................. myJSFuncOnaspxPage(); } thanks red Add this code where you want to invoke the function Me.RegisterStartupScript("KEY", "<script language=""JavaScript"">" & vbCrLf & _ vbTab & " myJSFuncOnaspxPage(); " & vbCrLf & "</script>") ...

calling a function in code behind from anchor tag of a link in aspx page
Hi How can i call a function(Submit_Click) in default.aspx.cs from anchor tag of a link in default.aspx .Tried by <li><a href="default.aspx" onclick="Submit_Click()">Submit</a> but not working...   can anybody help me??ET501 You can use the below method <a href="?id=1">Test</a>protected void Page_Load(object sender, EventArgs e) {if (Request.QueryString["id"] == "1") test(); }public void test() {Response.Write("Hello world"); } HCHaissam Abdul MalakMCAD.NET| Blog | Hi Actually...

how to call a function created in html page from the code behind page
this is my html page code: (webform) ============================================================ <%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="HRIS.test" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>test</title> <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR"> <meta content="Visual Basic 7.0" name="CODE_LANGUAGE"> <met...

Call a javascript function from a report, the function is in aspx page
Hi    How can I go about calling a javascript from from a report. The function is in teh code behind aspx page. When a user clicks a link on the report, this function needs to be called. Further, the report sits in an iframe of the aspx page. So somehow I need access to the aspx page without opening any other pages. I tried using this ="javascript:void SelectTab('tabScoreCard',EnergyExpert_" + Fields!EnergyExpertKey.Value.ToString() + "')"  but that gives me an error of no object found, when the user hits the link on the report to go back t...

calling code behind function from window.onload javascript function
Hi Gurus, I have a requirement like below. In my code behind file "MyPage.aspx.cs" file I have a function like below:void PopulateAccount(int AccountNumber) { this.AccountNumber.Text = AccountNumber; }I want to call this function from JavaScript (inside the window.onload function) from my MyPage.aspx page, something like below: window.onload = function() { // I need to call my PopulateAccount method inside this function so that it can populate the AccountNumber Text Box }  is this possible ?. Please help me how to do this . I am using ASP.Net 1.1 with C#....

accessing a code behind function from aspx page
I have a function in the code behind and am trying to access it as follows: <asp:label id="msg" runat="server" text="Data is <% =MyFunction() %>" /> when I run the page I get Data is the result of the function is not displayed.  The function does work if I just put it on the page Data is <%=MyFunction()%> The problem seems to be the quotes or that it is being called from inside a control.  Any thoughts? P.S. I know I can programatically say msg.text = "Data is " & MyFunction() - but I have other reasons for wanting to do it in the aspx page. thanksBJ D...

Calling code behind function from aspx file ?
I write web application in csharp.I have field which store data,call that A field , but when display data on datagrid , i want to encode .public string Encode_data(string dataraw){    ........   return string_encode;} In aspx file :<asp:datagrid>    <columns>           <asp:TemplateColumn>              <ItemTemplate>              &...

Calling a public function from a code behind page
With vb in have created a vb class file in my project in which i am storing common functions which are used in various code behind pages. When I instantiate the common class from the code behind page the autocomplete drop down doesnt contain the common functions I have created but it does contain constants which I have created in the common class file.Is there something else I need to do?Cheers. have you build the project ?Fadil Alnassar | FREE Nodil Tab Control What is the identifier...

call a function in vb code from aspx page
I am using version 2003 using vb as code behind. How can i call a function written in my vb code behindinside my .aspx page ie,I have to fill a dropdown box with some hard coded items( not in database)in one case and some other hard coded items in another case. 1. How can i dynamically change the content from code behind and make it list    in a .aspx page? 2. how can I call a function written in my code behind    from the asp, if I have to make a table hidden and visible based on a condition.I have written the vb function as belowPublic...

Custom Control: Calling a function on calling page FROM a custom control ? help !!
I have a custom control placed on many pages, to make things simple, basically what I want to do is Call a function on the calling page from the custom control ieAnyone have any ideas, simple solution would be good !!  This is the code I have myControl.ascx.vbPublic Partial Class myControl    Inherits System.Web.UI.UserControl    Protected Sub testButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testButton.Click        'call save function on PersonalDetails.aspx.vb  &...

Web resources about - function call inside aspx page for function in code behind not executing? -

Self-executing rule - Wikipedia, the free encyclopedia
The self-executing rule , also known as " deem and pass ", is procedural measure used by the U.S. House of Representatives to approve legislation. ...

Saudi Arabia condemned for executing prominent Shiite cleric on terrorism charges
Saudi Arabia executes a prominent Shiite Muslim cleric alongside dozens of al-Qaeda members, stirring a rise in sectarian tensions across the ...

Islamic State video purports to show boy executing two Russian 'spies'
Executions of captives by the Sunni Muslim militants of the Islamic State have become grimly commonplace, but a newly surfaced video featured ...

Parramatta shooting: police leave empty-handed after executing search warrant at mosque
Police executed a search warrant at a Parramatta mosque overnight as part of their investigations into the fatal shooting on Friday of a civilian ...

US states having trouble executing their citizens
Despite a Supreme Court ruling allowing a controversial drug to be used for lethal injections in Oklahoma, death-penalty states are finding it ...

Islamic State video purports to show boy executing 'Russian spies'
Islamic State releases video that purports to show a young boy executing two men accused of working for Russian intelligence.

Boko Haram executing elderly in northeast Nigeria
Islamic extremists in northeast Nigeria are turning their guns on elderly people, killing more than 50 this week in a new tactic that has instilled ...

New iOS security exploit lets apps read users’ information by executing unsigned code
Security expert Charlie Miller has found a flaw in code signing on iOS devices (via Forbes) that allows developers to sneak malware apps onto ...

Law Journal Apologizes For Article About Executing Law Professors, Professor Resigns
Insane law review article prompts professor's resignation... but how did he get hired in the first place?

Resources last updated: 1/19/2016 1:37:45 AM