.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

C++ Q&A: FileType Icon Detector App, Custom Context Menus, Unreferenced Variables and String Convers

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

More Related Resource Links

BinaryFormatter, SortedSet base class and a few instance variables.

/* This example successfully serializes and deserializes the SortedSet<string> base contents, but all the instance variables show up uninitialized. Here's the output: n1: 0 n2: 0 str: s == "String 1" s == "String 2" s == "String 3" Any ideas? */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; using System.IO; [Serializable] public class MyObject : SortedSet<string> {     public MyObject() : base() { }     protected MyObject(SerializationInfo info, StreamingContext context)         : base(info, context)     {     }     public int n1 = 0;     public int n2 = 0;     public String str = null; } namespace BasicBinarySerializationInheritanceFromSortedSet {     class BasicBinarySerializationInheritenaceFromSortedSetTest     {         static void Main(string[] args)         {             {                 MyObject obj = new MyObject();   &nb

Custom security via connection string

Hi Is it possible to pass information into the SQL Server relational engine via the connection string in the same way as it can be done for Analysis Services? I need to generate a user context for a forms authentication application (i.e. no windows user accounts). SSAS allows you to pass in a list of database roles or a customdata parameter on the connection string. These can be used inside the database in lieu of a windows identity. I am wondering if there are equivalent parameters available for the SQL connection string.  I guess that I could create SQL logins from each of the forms users with a system generated password and then pass the uid and password on the connection string but this seems unnecessarily complicated. Andrew Wiles - www.it-workplace.com - MDX made simple

Unable to build connection string using Package Level variables from the AcquireConnection fonction

Hi all! In SSIS 2008, within a script component trying to refer to a package level variables that was added to the ReadOnlyVariables collection of the component, the following fails within the AcquireConnnection function and I get this error: Error 1 Validation error. Test1: Test1: Microsoft.SqlServer.Dts.Pipeline.ReadOnlyVariablesNotAvailableException: The collection of variables locked for read access is not available at this point.     à Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception e)     à Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.AcquireConnections(Object transaction)     à Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper100 wrapper, Object transaction)   string connectionString = "DSN=" + this.Variables.MYDSN; Conn = new OdbcConnection(connectionString); Conn.Open();     If I move the previous code in the PreExecute function, it runs fine though.   Then, if I move the connectionString variable to the class definition, and populate it from within the PreExecute function and leave the last 2 lines in the AcquireConnection function, I get the following error: Error 1 Validation error. Test1: Test1: System.InvalidOperationException: The ConnectionString property

MaskedEditor with custom prompt string

HiIs it possible to set a prompt to the masked editor. I would like the textbox to show "dd/mm/yyyy" before giving it focus and while the user enters the date, so the "dd/mm/yyyy" is replaced while typing the date.Is that possible ?

How does one create context-sensitive custom help files?

We are an ISV and would like to know how to add a feature to our solution that uses the existing help functionality to display help based on the user type and context of that user type in the system.  I have been searching to no avail, if there is a How-To article somewhere I'd love a link! Thanks, -Torrance R. MillerIntegrating the future into today

write Custom MemberShip provdider only to read the connection string from other file

hi,    In asp.net mvc project I am using MYSQlMemberShipProvider. Now I want that instead of reading the connection string from web.config file, it will read the connection string from external file every time. So that I am implementing the cutsom mebership provider class, this class inherits the MemberShipProvider class.    But the problem is that if I inherits the MemberShipProvider class then I have to impelment all of its method in my cutsom membership provider class, But I want to use all other inbuilt methods of MemeberShip. What can i do.I only want to add the code like below: public class CustomSqlMembershipProvider :MembershipProvider    {        public override void Initialize(string name, NameValueCollection configs)        {            base.Initialize(name, configs);                Connectionstring objProducts = // redaing the connection string.   }}But on compiltaion it is giving me the error does not implement inherit abstract member. Please Suggest me any idea.        Thanks In AdanaceAayushi

Custom Task Icon issue

Hi I'm developping a custom SSIS task I added an icon to the project I set the build action to embedded resource I also added the dts attribute icon related element as [ DtsTask(.....   IconResource = "Mynamespace.iconfilename.ico", .......   But the icon doesn't appear when I drag the task in the design surface, once I want to test it, so what's wrong Thanks   The complexity resides in the simplicity

Setting SharePoint 2010 Form Fields Using Query String Variables


Hi All,

I have a requirement to populate sharepoint form field value with query string while uploading document to document library.

While uploading the document to document library, I want to populate claim number available from query string in a pop up page i.e in my case EditForm.aspx, Located at http://servername:port/sitename/documentlibraryname/forms/EditForm.aspx.

Additional Information:

  • Created document library and added custom columns like claim number etc..
  • Created a view to filter uploaded documents as per claim number.

Server Details:

  • Windows Server 2008 R2
  • SharePoint 2010
  • SQL Server 2008 R2

I have written javascript for the same, but not sure where exactly to add the code in EditForm.aspx page.

Any help on this would be greatly appreciated.

Thanking you in advacne.



Implementing custom ValidationFor to show an error icon with a tooltip instead of just text for c


I got the problem that my implementation (see source below) only shows the validation error message after server side validation an NOT

after clientside validation! My questions is, how can you extend or implement to show the validation error message also on client-side validation.

Unfortunately I have not found any other info source about this subject, so any help will be very much appreciated!

 public static string ErrorMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
            string modelName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression));
            FormContext formContext = htmlHelper.ViewContext.FormContext;

            if (!htmlHelper.ViewData.ModelState.ContainsKey(modelName) && formContext == null)
                return null;

            ModelState modelState = htmlHelper.ViewData.ModelState[modelName];
            ModelErrorCollection modelErrors = (modelState == null) ? null : modelState.Errors;
            ModelError modelError = ((modelErrors == null) || (modelErrors.Count == 0)) ? null : modelErrors[0];

            if (modelError == null && formContext == null)

How do I get a custom context menu to show up???

Okay, I just started back working on my web browser using Visual Basic 2K8, and I want to have my custom context menu show up when the user clicks inside the browser..... This is what I have...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Tab")
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        Int = Int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(UrlLocation.Text)
    End Sub

That is where I suspect the bit of code will have to go... Since I'm using Tab Control instead of the WebBrowser...

Icon for custom content type



I could not find anything concerning custom icons for content types. I have defined a custom task content type and now I want to assign a custom icon for it. The only way to set item icons I know is to edit the DOCICON.XML, but I do not have a file extension here.

Is there a way to do it programmatically?

Do Membership Roles work with custom connection string?


Hi all, plz help with one issue.
I have Membership configured with IIS7, tables for it located in my own database, created with aspnet_regsql utility, and I am using custom connection string to access it.

This is part of web.config related to Membership :

        <add connectionString="Server=CORESERVER\SQLExpress;Database=Shop;User ID=Tema;Password=Matrix" name="CustomSqlConnection" />
    <profile enabled="true">
            <add name="CustomSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="CustomSqlConnection" />
    <roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
            <add name="CustomSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="CustomSqlConnection" />
    <membership defaultProvider="CustomSqlMemberPr

Creating Variables in "Parent" from Custom Activities in Code


Using Workflow 4, I've created a series of custom activities (e.g. Create Email, Upload Email To Document Management System etc.) that need to pass data between each other during execution within a "parent" workflow.. I've read that the recommended method to do this is by using variables declared at the correct scope.  This is easy to do in the designer, so in a standard flow diagram or sequence I create my variables manually, then drop in my custom activities as "children" and assign variables to their InArguments/OutArguments as appropriate.

Unfortunately, this is VERY manual and I'd like to do it in code if possible.   I know that I can create an OutArgument to pass the value back to the parent workflow.. but I need to dynamically create the workflow variable to store that value in as well.. I've read in other posts about people wanting to do similar things..

e.g. http://social.msdn.microsoft.com/Forums/en/wfprerelease/thread/4958777a-77c3-448b-aac5-6933eaf726f5

..some of them have tried using the NativeActivityContext.Property (doesn't work directly between two "siblings", they have to be put in a custom container that sets the needed values on its own context p

How do I Access Variables Between Custom Activities From Code?


Basically, I have custom activity and I have a variable in it that I would like to access in another custom actvity. It it possible to do this without writting the acutal workflow from code and still use the designer? The best way to describe it would be that I want to declare a global variable from within an activity that would be available to any other activity.

This is an example of what I am trying to:

public class activity1 : NativeActivity

    protected override void Execute(NativeActivityContext context)
      string text = "Sent between activities!";

And here is the activity in which I would like to get the contents of the property:

 public class activity2 : NativeActivity
    protected override void Execute(NativeActivityContext context)
      string text = "";
      text = Convert.ToString(context.Properties.Find("globalText"));

Stepping through the code shows that the "context" object has zero properties once I enter the second activity. According to different sources this should be working because the context object should still contain my property correct?

Accessing of STRING input data in custom plug-in algorithm



We have some string columns in input data, how can I access the string value instead of double one (MiningCase.DoubleValue)  during training and predicion?



EF 4.1 connection string code first and object context


I have a question about using  an existing sql express(from a web host) with entity framework 4.1) and using an existing database  

Does this map directly using the following method. I posted this question in the msdn site and I really did not get a very good response so I hope someone helps out. my question Is what is the best way to map to an existing database on a web host    

  http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-code-first-walkthrough.aspx here is using a sql  default constructor

http://msdn.microsoft.com/en-us/library/bb896291.aspx you have to pre-configure entity framework here ....

I was wondering is this the way you do it using objectcontext

Public class  Blog context: Db context

public Blogcontext (Db connection connection)


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