.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

very weird method in partial class not listed in intellisense

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

I have created partial class for winform many times with no problem. When doing the same thing in asp.net I am stucked even with the most basic sample code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
protected void Page

View Complete Post

More Related Resource Links

Extension Method ForEach for ArrayList class

Hi,I need to create an extension method(ForEach) for arraylist classI have created an extension method for Array class but cannot do that for arraylist.Please help me namespace MyExtension { public static class IEnumerableExtension { public static void ForEach<T>(this IEnumerable<T> list, Action<T> action) { if (action == null) throw new ArgumentNullException("action"); foreach (T item in list) { action(item); } } } } Any Help Shall be appreciatedThanks

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

EXPERT: avoiding weird refresh behavior of Eval method in a tabpanel

I have this control in a detailsview:<asp:DropDownList ID="ddlEventStartDay" SelectedValue='<%#Cdate(Eval("startdate")).Day %>' CssClass="textbox" runat="server">    <asp:ListItem Value="1" Text="01" />    <asp:ListItem Value="2" Text="02" />    <asp:ListItem Value="3" Text="03" />    <asp:ListItem Value="4" Text="04" />    <asp:ListItem Value="5" Text="05" />    <asp:ListItem Value="6" Text="06" />    <asp:ListItem Value="7" Text="07" />    <asp:ListItem Value="8" Text="08" />    <asp:ListItem Value="9" Text="09" />    <asp:ListItem Value="10" Text="10" />    <asp:ListItem Value="11" Text="11" />    <asp:ListItem Value="12" Text="12" />    <asp:ListItem Value="13" Text="13" />    <asp:ListItem Value="14" Text="14" />    <asp:ListItem Val

[] brackets before a class or method Declaration

Hi Guys,Some times we have [] brackets before a class or method Declaration.  Can anyone guide me please in understanding those squre brackets.  what do we write in those and what they represent. like this [SerializableAttribute][ObsoleteAttribute]class Moon { }Thanks in advance.

Weird Exception: Method not found: 'Double System.Windows.Controls.ScrollViewer.get_ContentHorizon

Hi guys I have an XBAP application that uses a Xamdatagrid from Infragistics. I have some filtering on this grid, that rebinds after a filter. The problem is, when a user has scrolled to a certain point and then filters, the rebinding causes the grid to scroll to the beginning position of the grid. Now how I solve this is by getting an instance of the ScrollViewer, I get the ScrollViewer.ContentHorizontalOffset and then I do a ScrollViewer.ScrollToHorizontalOffset after it filters.   Now here comes the problem. For 99% of the users of this xbap app, this will work absolutely fine. Most, if not all of the users run exactly the same machines, XP 64 bit with 8GB RAM. The other 1% get the error: Method not found: 'Double System.Windows.Controls.ScrollViewer.get_ContentHorizontalOffset()'. I cannot reproduce this error on my own box, our dev server or our production server, it is a phantom exception that only pops up on a certain condition. I have even wrapped the "offending" code in a try catch and it still doesn't solve it. If I set the DispatcherUnhandledExceptionArgs Handled to true, it works, but it doesn't feel right. How is this possible? If the method doesn't exist, how can it compile? Why does that method exist for 99% of the other users running the exact same machines? I have googled my fingers raw without any valid results and this issue is frustrat

Is it possible to add a class method to CLR base class like Date?

Hi All, I would like to add a class method like ParseYYYYMMDD to the Date base class. So that I can use the following code. Dim result As Date = Date.ParseYYYYMMDD(dateString) Any idea? Is it possible via extension? Thanks! Regards, AlexAlex Lau from HKSAR

how to get a class reference as a reference and not a string to send for a generic method

I got some property that i get using generic method, there for I dont have it's <T>and I want to send it to another generic method but , how the heck do I get it's <T> :P?please look at the code below to understandit gets an entity framework objects, scan all it's properties and if the property is another entity framework object it would send it back to him self , the issue is that i dont know the new object <T> to send it back to him self :(search for the bold part to see what i'm missing//contains objects which we added so there wont be double adding private List<object> _addedObjects; public FakeGenericRepositoryExtension() { _addedObjects = new List<object>(); } public void Create<T>(T entity) where T : class { //add to created objects _addedObjects.Add(entity); //do something with object //... //start recircle process Type entityType = typeof(T); //run thrue each member of Type foreach (var member in typeof(Type).GetProperties()) { //get member value var member_value = member.GetValue(entity, null); //if not null //we must test this otherwise we can't get .BaseType if (member_value != null) { //get current member's base type string memberBaseType = member.GetValue(entity, null).GetType().BaseTyp

C#NET2008 FrmMain using DELEGATE CLASS Method



Hullo Good Guys,


I am back here seeking help. Please Help me.


Here us the description of what I was ihstructed to do by the System Analyst.


Create DELEGATE Class to perform Mortgage computation and return the result back to the calling FrmMortgage.cs. Apparently my coding are not working as I am not familiar with DELEGATE Class


Here are the Erro

Calling a static method in a static class from a base class.


I have the following static class and method:

public static class GenericList


      public static List<DocumentElement> PopulateGenericList()



What is the syntax to call the PopulteGenericList() method from a base class?



add an extra method to an existing class


Suppose that I want to implement another method for a class namely hasFiles for System.IO.Directory , How can I do that?

for example if I add <Extension()> _  tag before each function or Sub I can add a new function or method for each Control.

How should it be for a specific Class?

Unusual problem using a class method


I have a class that runs calculations on numbers and populates the results to my SQL database.  My code behind page instantiates the class object, and in a loop it makes use of the method five times (once per loop).  Essentially, my code behind collects the information from controls and passes the information to the class method for processing.  The method works just fine most of the time.

On one of the iterations I get a error before the code even gets to the class.  The error is, "Arithmetic operation resulted in an overflow."  What strikes me as odd is that while stepping through the code, the loop crashes with that error before getting to the class that runs the calculations.  Additionally, no arethmetic operations are performed on the form's code-behind page (which calls the method).  I even put a break-point on the class constructor but the code crashed before reaching that constructor.

The information being sent is the results of matches from a sporting event.  As a troubleshooting measure I changed the order of the matches by deleting them an re-entering them into the database in a different order.  Again only this one particular match crashed.

Here is the code that crashes:

cRating.SetRating(dMatchDate, iSetID, 8, iHPlayerID, 

TCP Client/Server communication: NetworkStream.Write() send partial data unless close() method is re

Hi to all,
I wrote a simple client-server application that comunicate through NetworkStream class. The problems comes when stream.close() and client.close() methods are called. It look like only the first 10415 bytes are sent once those methods are called. So, if the data to send is more than this size, it is automatically truncated.

If I  remove both stream/client close() methods from the code, the data is fully received whatever the size is. I tried various alternative solutions (the ones marked as comments in the sample code), but none of them works.
The only thing that seems to work is adding a manual delay before the close() methods execute with something like that:

For Counter as integer = 0 to 10

The problem is that after delay I still don't know if all the data has been transfered or not. In addition to that, I will have to wait 10 seconds before sending another request, even if the response is just a few bytes of data. I could change at runtime the number of seconds to wait according to the size of the data to send, but I still think that delay is not a solution and will cause adverse effects.

So, for now the only working solution is to remove both Stream/Client Close() methods from

Executing method of the Generic class using Reflection.



I have a generic class:

 abstract public class BaseTC<T>:IExecutable where T : Core, new()
    private Type2 testInfo;
    private Type1 settings;
    private T core = null;

and I want to load such class from library the class is located in, and create an instance of it and execute methods later on.

I know how to use non-generic classes, but no idea how to call the same with generics.

Intellisense / class reference not working in MembershipProvider derived class file in App_Code fold



I am new to ASP.NET and may be biting off more than I can chew, but I figure if I jump in the deep end I may learn more.

Can somebody tell me why the Visual Studio intellisense is not working in a newly created class file inside the App_Code folder?

I presume that System.Web is not being referenced from the App_Code folder correctly for some reason, because as soon as I type "using System.Web", everything is fine and then stops when I want to add ".Security" (no dropdown). I think this has an influence on the fact that the inherited MembershipProvider in my code is not highlighted/referenced and I cannot use the "Implement Abstract Class" option.

If I create a new class file in the root folder of my website, everything works fine. I have even tried to delete and recreate the file in my App_Code and it still did not work. I also tried to copy the file from my App_Code folder to the root and it still did not work. My code is as follows:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace PodcastManager
    public class

Accessing variables containing usercontrols in a partial class


Hello everyone,

Last night you guys here on this forum helped me in accessing properties of a dynamically loaded UC in an aspx page. Now i am facing another hiccup.

My code behind is : public partial class SiteUserControls_Message_Messages : BaseControl

In one of the click events i am loading three web users controls:

protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)

         SiteUserControls_Message_Create CreateNewMessageUC = Page.LoadControl(CreateMsgControl) as SiteUserControls_Message_Create; // typecasting the UC


Now i want to access this variable CreateNewMessageUC in another event like this:

protected void MarkAsUnreadLinkButton_OnClick(object sender, EventArgs e)




In My effort to make the UC variable global i have put that in class body liek this

public partial class SiteUserControls_Message_Messages : BaseControl

       SiteUserControls_Message_Create CreateNewMessageUC;


But when i access teh variable in another event i

Partial Class


Is it possible to write the definition of the partial method in two partial classes?

For Example: 

Public partial class A 


      public partial void ShowName();


Public partial class A



Is it possible to define ShowName() method in both the places?

Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust



I want to pass parameter to Silverlight Control deployed as a Webpart.For this i used WebpartStorageAttribute for getting the values while configuring the Webpart.

It deployed Successfully but when i try to add webpart its raising the following error

Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: Could not load type 'Microsoft.SharePoint.WebPartPages.WebPartStorageAttribute' from assembly 'Microsoft.SharePoint, Version=14.900.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

Thanks in Advance

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