.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Passing Double Value to Function

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
Hi all,The scenario is this:I have a .aspx webform, with code behind to handle data entered by user, most fields are in double.At business layer, at other class, let say there is a function: public SaveData(value1 As double, value2 As double) as BooleanThus, when I call the function at code behind:SaveData(txtDouble.txt, txtDouble2.txt)The problem is when there is a empty text, it will throw an exception invalid cast to double value.Thus, I should change it to:Double value1 = 0.0 Double value2 = 0.0 double.TryParse(txtDouble.txt, out value1) double.TryParse(txtDouble2.txt, out value2) SaveData(value1, value2) I just wondering whether this is the correct way of writing it? And if I have more than 20 fields of double value, then I should declare additional 20 double value?Your input is much appreciated.Cheers!

View Complete Post

More Related Resource Links

Passing value from asp to javascript function


Here is the problem 

private void Page_Load(object sender, System.EventArgs e)

private void Page_Load(object sender, System.EventArgs e)




                                      int flag = 1;

                                       btn_ModifyApprove.Attributes.Add("onClick", "return ValidateModifyApproval('" + Flag + "');

How to : Generic error handling function. Passing GridViewUpdatedEventArgs as EventArgs

Hi, I want to build a generic error handling function for handling inseted, updated, deleted events from formview, gridview and detail view. I am still a bit new to C# so I have encoutered a simple problem that I cannot resolve and cannot find an answer while searching google.Right now I handle error with validator for generic validation but I need to catch BLL error.I have different event handler for the different type of event : protected void FormView_AjoutCompte_ItemInserted(object sender, FormViewInsertedEventArgs e) { if (e.Exception != null) { Afficher_Erreur(e.Exception); e.ExceptionHandled = true; } } protected void GridView_ListeUtilisateurs_RowUpdated(object sender, GridViewUpdatedEventArgs e) { if (e.Exception != null) { Afficher_Erreur(e.Exception); e.ExceptionHandled = true; } } protected void GridView_ListeUtilisateurs_RowDeleted(object sender, GridViewDeletedEventArgs e) { if (e.Exception != null) { Afficher_Erreur(e.Exception); e.ExceptionHandled = true; } } I want to create a generic function that will handle them all, a function such as : private void GestionDerreur(EventArgs e) { if (e.Exception != null) { Afficher_Erreur(e.Exception); e.Exc

Passing an array to Javascript function, and SetTimeout

Hi, I have a js function that takes an array (of strings) as a parameter. I read some data from DB and create the a parameter and pass it to js function but it only sees the first entry. Here is the sample ( i cut out unnecessary stuff):var singletext = new array();function ns6scroll(singletext) { setTimeout("ns6scroll(" + singletext + ")", spause); } In code behind: string[] saAlerts = new string[lsAlerts.Count]; int i = 0; foreach (DMSAlertDO oAlert in lsAlerts) { StringBuilder sbAlert = new StringBuilder(); sbAlert.Append("'<nobr align=\"center\">"); if (oAlert.NavigateUrl != string.Empty) sbAlert.Append("<a target=\"_blank\" class=\"scroller\" href=\"" + oAlert.NavigateUrl + "\">" + oAlert.AlertText + "</a></nobr>'"); else sbAlert.AppendFormat("{0}</nobr>'", oAlert.AlertText); saAlerts[i++] = sbAlert.ToString(); } if (!ClientScript.IsStartupScriptRegistered("StartScroller")) { StringBuilder sbScript = new StringBuilder(); sbScript.AppendFormat("<scr

SharePoint - Passing Dataview Row Arguments to a C# function from a button

RE: SharePoint - Passing Dataview Row infomration to a C# function I've done this with a asp.net Gridview. but does anybody have any examples on how to pass row information from an asp.net button in  SharePoint Dataview rows to an inline C# function? the button Repeats as follows: <asp:Button runat="server" Text="Delete" id="Delete{@ID}"  OnClick="DeleteDoc()"/> My function looks like this: void DeleteDoc(object sender, EventArgs e) { } I tried adding another parameter but get: No overload for 'DeleteDoc' matches delegate 'System.EventHandler' Thank you.

passing repeater container.dataitem to javascript function

I am collecting user roles into a single dimension string array. I have a repeater that its source set to that array. The repeater template includes list of checkboxes for the values in the array.The checkbox text is set to: Text='<%# Container.DataItem %>'All is good till this point.But I am trying to call a javascript function triggered by clickign a checkbox and pass it the container.dataitem, but the javascript doesn't seem to be reading the value and either complain about string not being in correct format or that treats the container.dataitem as a liter. This is the trial that didn't work (I tried many different things too):DetermineVal(<%# DataBinder.Eval(Container.DataItem) %>);determineval is my javascript functionCan I do that with a single dimension array?thank you in advance

Passing Double Quote "


Hi all,

I'm trying to passing field value adding double quote front and end for  Go To report action.

If  =fields!author_Name.value    is TEST

I want to make it as "TEST"

Tried following expression

=""" & Fields!Author_Name.Value & """


Result is   " & Fields!Author_Name.Value & "

I thought & will break "" but it is not.


Any idea?


Thank you


Passing invisible element to javascript function


I want to pass the name of a listbox to a javascript function which will make it visible. The listbox element must start out invisible. But when the server generates the source, it does not create the element because it is invisible. So the javascript functions doesn't get anything. How to do this?

    function promote(boxid) {
        document.getElementById(boxid).style.visibility = "visible";
        document.getElementById(boxid).style.zIndex = 100;


    <asp:ListBox ID="ListBox1" runat="server" CssClass="PosAbs0" Visible="False"
        SelectionMode="Multiple" ToolTip="Ctrl-Click to select multiple items">
        <asp:ListItem Selected="True">All Breed</asp:ListItem>

Passing variable into function in SQL Server from Access



I am trying to call a function in SQL Server 2005 from Access 2003.  It works fine with the constant value, but fails with a variable of the same value.  This works:

strSQL = "SELECT * FROM functionName (constantValue)"
rs.Open strSQL, cn 

But when I use variable in the parameter, I get error.  I have tried creating parameter objects in Access, but couldn't execute it and don't know if this is a way to go anyway.

Would appreciate for any help or suggestion.


Thank you

Passing two different references to a function?


I have a function called populateList(). I want it to take a reference to a Checkboxlist or a Dropdownlist, query the DB and fill the referenced list with values.

Is it possible to generalize the function to take a Checkboxlist or a Dropdownlist depending on what you pass?
Or, do I have to write two different functions, one for the Checkboxlist and one for the Dropdownlist?

I guess the my question is if theres a common object that covers both, like populateList(ref GeneralList list)

Thanks in advance!


Passing grid DataItem as an argument to javascript function.


in aspx page

<cmp:MenuItemInfo Text="Delete" onclick="javascript:deleteRow('## DataItem.ClientId ##')" />


In Javascript


function deleteRow(rowId)




but the arument is coming as a string '## DataItem.ClientId ##' instead of correct clientID.

Any help ?


Passing multiple arguments from a listview to a JavaScript function


Hello, I have been stuck on how to pass multiple to a JavaScript function in a item template of a list view. Below is my code. Does anyone know the process? Thank you.


                            <td style="width: 114px; height: 139px;">

                                <div style="width: 105px; height: auto">

                                    <img alt="" id="Image7" runat="server" src='<%# DataBinder.Eval(Container.DataItem,"images")%>'

                                        width="100" height="125" border="0" onmouseover='"javascript:show(<%# DataBinder.Eval(Container.DataItem,"images")%>)","(<%# DataBinder.Eval(Container.DataItem,"filename")%>)","(<%# DataBinder.Eval(Container.DataItem,"caption")%>)",1,234'

How to send C# double array to VC++ ActiveX COM Dll function.



I am using VC++ ActiveX dll in C# windows Application. ActiveX COM dll code is build using Visual C++ 6.0 and I have source code to update.

I want to create one method in ActiveX dll  accepting double array as an argument and invoking it from C# application.

I tried creating ActiveX method [GetData(double FAR* dStartPt, long nSize) ]. The corresponding AXInterop Dll in C# application shows

[GetData(ref double  dStartPt, int nSize) ] signature.

By this I am able to send a first element as ref, and tried to access other elements of array by  [dStartPt] incrementing (I think this is not right.) but it get only first element right and other zero.

could you please tell me where I am wrong. OR  information about sending array from C# to ActiveX.

[I search for SAFEARRAY but could not  add reference to C# project, and Activex Dll is developed long time ago.]



Passing parameters to delegate function


I need to convert the following C# code to VB.NET:

        public bool TryGetRewriteMatch(UrlContext url, out RedirectMatch match)
            // NOTE:  Normally this would use regular expression matches, cached database lookups, and/or dictionary lookups, etc.  It is hard coded for demo purposes...
            if (url.Path.StartsWith("/product/", StringComparison.InvariantCultureIgnoreCase))
                int productID = -1;
                if (url.Path.EndsWith("def.html"))
                    productID = 2;
                else if (url.Path.EndsWith("ghi.html"))
                    productID = 3;

                if (productID > 0)

Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

Passing values in pages


Hi! Friends..

how to pass the value from one page to another page in asp.net  with out Using State Management Concepts?

Like 1. cookies


        3. QueryStrings

     With out using the above should pass the values...

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend