.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 a valid condition as argument in c#

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

I have a requirement where i need to pass a full condition as the argument to a function and evaluate that function to decide whether to do certain functionality

for ex:

i have to call a function like this:



and in the function definition



  // evaluate the condition and do certain functionality.


thanks in advance. 

View Complete Post

More Related Resource Links

Passing a global parameter/argument to a workflow


I am using a hosted workflow designer to allow users to create their workflows. I would like them to be able to execute the workflow in a 'Test' mode, so I am trying to pass a parameter that indicates it is test mode.

In addition to the workflow being run from the rehosted designer, it will also be getting executed by an automated Workflow Console Application. So when the workflow is executed from the rehosted designer, it should execute in test mode. When it is executed from the console application, it should execute in production mode.

I thought I would just be able to pass a paramter indicating which mode to run it in, but the only way I can seem to get it to work is to have an Activity already on the workflow and setup the Argument for them through the designer and assign the expression prior to run time. The problem is that the user starts out with a blank workflow with no activities on it. I do not know which activity the user is going to add to the workflow, and I don't want them to have to be able to figure out how to configure arguments. It is an argument that should just always be there.

All the activities that I've made available to the user are inherited from a base class which inherits from NativeActivity. So is there anyway to dynamically bind the activities to the argument passed in at runtime in the base class?

I am invoking

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 Argument from Execute Process Task (SSIS) to a Batch File



I have a batch process set up, which executes fine as long as the name of the file is built in.  My Execute Process task in SSIS also runs this batch file with succes.

I would like to pass the name of the file as a parameter from the Task (SSIS) to this batch file.  Looks like I am doing something wrong because it is failing.

This is the batch file:
cd \Program Files\WS_FTP Pro\
wsftppro -s "local:D:\Folder1\Folder2\%1" -d HDMS:/To_HDMS/

---  The %1 is the parameter

The argument that I am passing in is in the 'StandardInputVariable'

Would really really appreciate some help!  Thanks so much!


Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

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...

Passing Data to a Cell in Excel



I have a webpage that is created in Visual Studio 2008 and programmed in C#.

I have a web form that prompts the user to enter a value into a text box.  For now, I do not have any validation on that field (I will be adding that later).

I need to pass the value that the user has entered to cell C1 of the excel spreadsheet (user_info.xls).

I understand that using excel is not ideal, but unforutnately need to try to make this work with the excel spreadsheet.

I do not have any code for this yet, because I honestly do not know how to begin.

The action of poulating the excel spreadsheet will be intialized from the On Click event of a Submit button.

Any suggestions would be much appreciated.

Thank you in advance for your assistance,


ReportViewer :: Failed to enable constraints. But my statement is valid!!

  • A
  • n error has occurred during report processing.
      • Exception has been thrown by the target of an invocation.
        • Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    Why do I keep getting this error, even when not using any data on the report. When I run the query in SQL server I get a resultset. However when I try to render the report I get this error.


    Passing HTML values from asp.net to asp


     We have a part of our website which is coded in classic asp. This takes the values of a login page (asp.net)  which uses 

    <input type="text" /> to hold the values and then submit them to the asp page using the following line of code -

    <input type="submit" value="Login" onClick="this.form.action='<%= SubmitURL() %>/login/login_user.asp?Type=Login&amp;this.form.encoding='application/x-www-form-urlencoded'; this.form.submit();" />

    The asp page then retrieves the values using the code -

    Value1 = Request.Form("Val1")

    We now have a requirement to pre-populate the login values to provide an automated login process but don't want to change the older asp code. When we try to assign values to the input text in the asp.net page by assigning the value runat="server" the login fails as it does not seem to carry over when the page is submitted.

    Is there a way where we can pre-populate the html textbox without making it unavailable to the asp page?


    how to multiple condition in if statement in asp.net C#



    i am using if condition to find out a time

    if(time=="08 AM)


    response.write"shift A";


    but problem is how can i put multiple condition in if like

    if(time=="06 AM" and "08 AM" and "07 AM")

    Path not valid.



    im trying to save a file, filename as current date and time.it will give an error.

    any ideas.

    here is my code

    string datetime=DateTime.Now.ToString();

    if (GridviewtoCSV("~/Admin/doc/Reports/" + batchid.ToString() + datetime + ".csv", transactiongrid) && GridviewtoPDF("~/Admin/doc/Reports/" + batchid.ToString() + datetime + ".pdf", transactiongrid))

    passing page title through a param


    Hello all,

       I am new to ASP.NET, and was wondering how to pass a Page title through a parameter.  In classic ASP I could just use something like: <title><%=Pagetitle%></title> but I cannot seem to get this to work in ASP.NET. 

    Thank you in advance,

    The New Guy... Smile 

    Passing Primary Key to User Control to Display Record Detail


    I'm building a user control to display detail information on a parent record. The user control will be displayed via an Ajax Modal Popup. The user control works and is displayed when expected. The problem that I'm having is that I'm not able to pass in the primary key for the parent. The control is displayed via the _ItemCommand event of a Repeater. In the markup for the user control, I explicity set the ContactId to 0 to avoid an error when the control loads (its still underdevelopment, eventually that I'll check if the value is valid).

    I was assuming that I could change the property in the _ItemCommand event, but obviously its not working.

    In the Page_Load event this code successfully sets the ContactId property of the control. The _ItemCommand event appears to set the value. However when I set a test label on the user control to the Me.ContactId, its showing '0' as if it was never passed in.

            UserControlContactDetail.ContactId = "1462"
            test.Text = UserControlContactDetail.ContactId

        Protected Sub RepeaterDirectory_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterDirectory.ItemCommand

    Protected Sub RepeaterDirectory_ItemCommand(By
    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