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

Top 5 Contributors of the Month
Post New Web Links

Assigning a value to const int

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net


I have a const int varable to which i need to assing a value from config value .When I  was giving it as

public const int MaxValue = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["MaxVal"].ToString());;

I was getting a error .Can anyone help me out

View Complete Post

More Related Resource Links

.NET Matters: Const in C#, Exception Filters, IWin32Window, and More


Welcome to . NET Matters. This new column will delve into the ins and outs of the Microsoft® . NET Framework, answering readers' questions on various topics related to its extensive libraries, languages, and the common language runtime.

Stephen Toub

MSDN Magazine April 2004

Assigning users when creating a list item in a workflow


I'm using a workflow to assign tasks to users.  When I try to assign the task to a group (set in the workflow designer), the workflow gives me an error.  When I change the assign to property to a single user, the workflow works perfectly.  How do I get the workflow to assign the task to the group?  Or if that's not possible, can I get it to assign it to more than one user?


Trouble assigning properties for multiple CSS classes

Hi Can anyone tell me why the first block of CSS below works, but the second one doesn't? Thanks Block 1: (works) <style type="text/css">  .FB  {      margin-bottom: 0.5in;      margin-left: 0.5in;      text-align: left;      float: left  }  .FB  {      color: Black;  }</style> Block 2: (Doesn't work - all I get for FB is color: Black)<style type="text/css">  .SomeOtherClass, FB  {      margin-bottom: 0.5in;      margin-left: 0.5in;      text-align: left;      float: left  }  .FB  {      color: Black;  }</style>

TransactedTeceiveScope not persisting when assigning value to a variable

In a TransactedTeceiveScope I write to a DB table (via a custom activity SaveApprovalRequest using EF) and want to execute some other activities. With SaveApprovalRequest being the only acitivty workflow persistance works fine. As soon as I addionally assign a value to a variable the workflow no longer gets persisted. Why? I am using EF to write to a table in the same DB where . Below a minimal test case. With the assign activity the workflow does not persist. Without the assign activity the workflow does persist. <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Warning,ActivityTracing" propagateActivity="true"> <listeners> <add name="svcTraceFile" type="System.Diagnostics.XmlWriterTraceListener, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="X:\temp\Logs\ApprovalWorkflowTrace.svclog" traceOutputOptions="Timestamp"> <filter type="" /> </add> </listeners> </source> </sources> </system.diagnostics> <connectionStrings> <add name="approval" connectionString="Data Source=(local);Initial Catalog=Approv

assigning spn to service account

I have installed MOSS 2007 to use Kerberos. Prior to the installation I assigned SPN HTTP/servername.domain to each of my service accounts: Farm Account, Content Pool, Shared Services Pool and Shared Services Account. I did this knowing that I would have to add / drop SPNs later, according to port numbers. (I followed guides by Scott Hillier and Martin Kearn). My question is: what specific service/app pool do I assign to these accounts? When all have the same generic SPN that I assigned originally everything works, but I receive KDC error #4 every 30 minutes or so. KDC error 4 states that there are 'multiple accounts with name HTTP/*****.*** of type DS_SERVICE_PRINCIPAL_NAME. I have been using trial and error in assigning variations of the HTTP service (using port numbers from my MOSS instance).Is there a better way? Because this is not working so well.

Assigning a task based on 'person' column.

Hi All, I am creating an employee of the month type feature in Visual Studio. This involves a nominations list (where users can submit a nomination) and a custom task list (based on workflow tasks) In a nomination, a "Line Manager" is entered, and is set up as a Person Column. In code, I create a task, and I am trying to assign the task to the line manager. The code I have is: taskProperties.AssignedTo = workflowProperties.Item[ "Line Manager"].ToString(); This does return the name of the nominator (but with a prefix, usually #795; (or something like that)). How can I assign a task in code to a user based on the selection of a Person field (chosen using People Picker)?    Andrew Berry - Software analyst/Developer

Assigning a reusable workflow to all content types in a list in one operation?

When creating a reusable workflow I choose a base content type. I would really like to assign this workflow to the content type at site collection top level and get it to automatically work in all lists that include this content type, and also have it set to work for all children of this top level content type. It seems to me that I have to manually associate this workflow to all lists and content types? I am missing something here? Henning

Problem assigning a value to a variable in a Script Task

I've found loads of posts with the error I'm seeing: "The type of the value being assigned to variable [XXX] differs from the current variable type". However, I can't see anything that matches my scenario.  I'm simply trying to assign a value to a variable BEFORE passing the variable to an Execute SQL Task. I want to assign "true" or "false" to a Boolean variable called LogError, but as I got this error, I tried instead to assign 0 or 1 to it after converting it to an Int16 variable, but got the same result. I can see all manner of posts that make me wonder what I may have problems with next when I try to pass this variable to my stored proc that's expecting a BIT, but for now, I'd love SSIS to simply assign the value to the variable! Any ideas?

Task assigning in Sharepoint workflow

Hi, I am designing a workflow in SharePoint designer. I have created an approval task process (Start Approval process) and assigned it to a SharePoint group. The requirement is when the task is assigned to a group, if the group has got only one user it should appear under "My task" for the user and not as "My Group Task". If the group for with the tasks has been assigned has got more than one user, the task should appear as "My Group Task". I would not like to hardcode the user ID on the workflow since it would lead to redeployment of workflow every time the user changes the department. Therefore I have created user groups for each department and users are assigned to these groups. Please assist me building up the logic. Thanks. Regards, Sriju  

assigning workflow tasks

Hi, I'm trying to create a workflow in sharepoint designer which will assign the workflow task to a specific user based on a field. I'm using the "Collect Data from This User" action. I have two lists, "cost centre" and "purchase order". I've put the layout of them below. I want the workflow task generated from the Purchase Order to assign the workflow task to the Approver in Cost Centres based on the Cost Centre field. In Sharepoint designer I have done the following: Lookup Source: Cost Centres Field: Approver Find Field : Cost Centres:Cost Centre Value: Purchase Order:Cost Centre Cost Centres (List) Cost Centre                  Approver 0010                              Chris 0020                              Sarah Purchase Order (List) Cost Centre 0010 When I create a new item in Purchase Orders List with a Cost Centre field that matches a field in Cost Centres List, there is no-one assigned in the task generated from purchase orders list. Any ideas

CreateUserWizard creating dupicate user while assigning Role.

protected void CreateUserWizard1_CreatedUser(object sender,  EventArgs e){Roles.AddUserToRole((sender as CreateUserWizard).UserName, "Customers");} CreateUserWizard is creating dupicate user while assigning Role.How can we assign Role without duplicating user record? I've observed ApplicationID for assigning Role is Differenent than Creating New User, so when ever Role assigning comes in, it creates  same user again with new UserID. Is it related to Web.Config in some way? As when I try to create user from "VisualStudio/Website/ASP.net Configuration" even then two users with same usernames are entered in aspnet_users with Different ApplicationID and UserID. One user has Role and another duplicate user is without Role status of IsApproved=1.Please help me to resolve this issue.Thanks!  

WCF calling webservice - assigning return value taking a long time

0 down vote favorite

I have a wcf service (WCF_A ) which calls another wcf service (WCF_B) (currently I am hosting the WCF_B on my local machine with my credentials – as windows service), WCF_B internally makes a call to a webservice (WS01) that is hosted on the IIS. I have created a test client and call the WCF_A -> WCF_B -> WS01. Just before making the call to (WS01) I start a timer and I stop the timer when the webservice call comes back and the result is assigned to a variable, the flow is as below WCF_B

1)  Debug.WriteLine(“Call to webservice”) 
2)  Starttimer 
3)  Var result = WS01.Function(xxxx) 
4)  Stop

Assigning values from a Database to a Label



I want to select all the values from a table in my database and then put each value in order into labels that are on the asp page.

I can Select all the values from that database fine but I am rather stuck as how to put the values into the individual labels? Here is the code I have connecting to my database.

  Dim cmd As New SqlCommand
            Dim myConnection As New SqlConnection("Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Alerts.mdf;User Instance=true")

            cmd.Connection = myConnection
            cmd.CommandText = "SELECT DateTime, Description FROM EmailTemplateLoad"


        Catch ex As Exception

        End Try

How can I put the DateTime value into Label1 and the Decription into Label2??

I have had a nose about but can't seem to find the information I need.

Any pointers greatly appreciated.

Assigning XML Tag Names Within ASP Web Service Returning Jagged Array



I am using an ASP webservice to return a jagged array.  I need to be able to define the tags names in the XML which is returned.  How do I do this?


Code and Example XML follow.




        orderListId = new string[100];
        orderListTime = new string[100];
        orderListEmail = new string[100];
        orderListStatus = new string[100];
        orderListSubtotal = new string[100];

        int orderCount = 0;
        foreach (DataRow drRow in dtResult.Rows)
            orderListId[orderCount] = (drRow["SubmittedFormId"].ToString());
            orderListTime[orderCount] = (drRow["SubmitTime"].ToString());
            orderListEmail[orderCount] = (drRow[&quo

assigning database roles with smo (C#)


Hi All,

I'm using VS C# express with SQL 2005 express.

I have the following problem:

I would like to assign database roles in a given database for a login by using smo. Let's say:

I have a Login, created with smo named MyLogin and a database name MyDatabase.

How can I map MyLogin to MyDatabase and give for example db_datawriter database role membership for it, using SMO?

I do not find the way, propably I miss something...

Any help is highly appreciated, I would be thanksfull if one could give a code example to solve this.




how to break line while assigning value using Javascript


hi all ;

i ve a string like

var Ans="a<br>b<br>c";

wen i assigned input using document.getElementById(id).value = Ans;

it display input as it is

i wanna show input lyk 




i am tryin to replace <br>wit "\n" but it is not working... it is showing 

a<br>b<br>c or


Script Component - Assigning value to a variable problem


I have a Script Component and in it I want to assign a value from a row to a variable. I am iterating through a For Each Loop, so I am only getting 1 row at a time. I have a variable declared as ScriptedSaleID and the following code in my Input0_ProcessinputRow method:



myvars As IDTSVariables100

        'We lock the variable for writing. 1st parameter is the name of the variable
        VariableDispenser.LockOneForWrite("ScriptedSaleID", myvars)

        'Now we can write the value to the variable
        myvars(0).Value = Row.SaleID

        'Now we unlock the variables

My problem is

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