.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

Howto set the value of webgridcolumn.format in the class file?

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :ASP.Net
About:  I want to define format string of the webgridcolumn by myself.Example:There is a ID column in a webgrid ,i want the cell of this column filled the data like "<a href="/Default/@ID">@ID</a>"Code: Microsoft.WebPages.Helpers.WebGrid mygrid = new Microsoft.WebPages.Helpers.WebGrid(tarobjs,canPage:Convert.ToBoolean(data.Groups["enablepager"].Value), rowsPerPage: Convert.ToInt32(data.Groups["pagesize"].Value));                 Microsoft.WebPages.Helpers.WebGridColumn[] columns = new Microsoft.WebPages.Helpers.WebGridColumn[data.Groups["col"].Captures.Count];                                 for (int i = 0; i < columns.Length; i++ )                 {                     columns[i] = mygrid.Column(columnName: data.Groups["col"].Captures[i].Value, header: data.Groups["headertitle"].Captures[i].Value);                                      }                 HtmlString myhtml = (HtmlString)mygrid.GetHtml(columns:colu

View Complete Post

More Related Resource Links

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it e


Here is the page directive for the page that throws the error:

@ Page language="c#" Inherits="University.AspNet.Index" CodeFile="Index.aspx.cs" %>

The code behind file Index.aspx.cs starts like this:

using University.Framework.UI;

namespace University.AspNet

public partial class Index : University.Framework.UI.HomePage

The code behind is extending this HomePage class, which is in turn an extenstion of another class University.Framework.UI.Page, which extends the System.Web.UI.Page class.

Am I misusing the I

Inside Windows: An In-Depth Look into the Win32 Portable Executable File Format, Part 2


The Win32 Portable Executable File Format (PE) was designed to be a standard executable format for use on all versions of the operating systems on all supported processors. Since its introduction, the PE format has undergone incremental changes, and the introduction of 64-bit Windows has required a few more. Part 1 of this series presented an overview and covered RVAs, the data directory, and the headers. This month in Part 2 the various sections of the executable are explored. The discussion includes the exports section, export forwarding, binding, and delayloading. The debug directory, thread local storage, and the resources sections are also covered.

Matt Pietrek

MSDN Magazine March 2002

Inside Windows: An In-Depth Look into the Win32 Portable Executable File Format


A good understanding of the Portable Executable (PE) file format leads to a good understanding of the operating system. If you know what's in your DLLs and EXEs, you'll be a more knowledgeable programmer. This article, the first of a two-part series, looks at the changes to the PE format that have occurred over the last few years, along with an overview of the format itself. After this update, the author discusses how the PE format fits into applications written for .NET, PE file sections, RVAs, the DataDirectory, and the importing of functions. An appendix includes lists of the relevant image header structures and their descriptions.

Matt Pietrek

MSDN Magazine February 2002

How do I find the file path from a namespace.class name?


I'm programatically looking ito a .aspx file and getting the file class name declared in its CodeBehind. For example, when analyzing myFile.aspx I read in its Page Directive and found its CodeBehind equals "myApplication\myPage.aspx.vb". Then I use the code below:


Dim Assm As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("myApplication\bin\myApplication.dll")
Dim ClassType As Type = Assm.GetType("myApplication\myPage.aspx.vb")
' myBaseType = "myApplication.Forms.BasePage"
Dim myBaseType As System.Type = ClassType.BaseType


Now I want to read the BaseFile (class = myApplication.Forms.BasePage). However, to read in this file, I need I need to get its full path instead of its namespace.class hiearchy. In this case, the BasePage is wrapped in a different namespace declaration thus I cannot just change the '.' to '\' in order to get the path.

How can I get the path of BasePage so I can read it? Thank you - Frank

File Stream Class

 I am trying to write to a text file while protecting it from concurrent access. What is the advantage of fileStream.lock ? (when I created a filestream in the code below, the file seemed to be protected from other processes using it). I am not sure if I need to use filestream.lock below. Please advise ..            Public Shared Sub writeToLogFile(ByVal logMessage As String)         Try             Dim strLogMessage As String = String.Empty             Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt")             Dim swLog As StreamWriter             strLogMessage =  DateTime.Now.ToLongTimeString().ToString() & " ==> " & logMessage             Dim fileStream As New FileStream(strLogFile, FileMode.Append)            ' Lock all of the file after creating the filestream object             fileStream.Lock(0, fileStream.Length)      &nb

How to get a file path in a class library used by asp.net

 Hello,   I have an asp.net application which employs a class project to process xml files. I have an xsd file within the class project. To load the xsd file, I am not sure which path I should use. The following code snippet loads the xsd, and reads the xsd using the StreamReader. I am not sure how to set the value for xsdPath variable.// 2- Read Schema file content StreamReader SR = new StreamReader(xsdPath); // 3- Create a new instance of XmlSchema object XmlSchema Schema = new XmlSchema(); // 4- Set Schema object by calling XmlSchema.Read() method Schema = XmlSchema.Read(SR, new ValidationEventHandler(ReaderSettings_ValidationEventHandler)); Thanks  

Access ViewState in Class File

The article Access ViewState in Class File was added by bhaarat on Wednesday, September 01, 2010.Many times we might need to access Viewstates in classfilewhich is not availablethis is a way to access the Viewstte in Class fileon code Behind%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits

snp file retains format of default printer from which it was created

This seems to be the case: MS Access 2000/2003 generates a snp report via VBA (Windows 2000/XP is the general environment for the enterprise).  The report is emailed to another individual.  When the recipient tries to print the report the print options apparently force the print job into the printer's override tray as "Print to Heavy Paper"; thereby causing the printer to wait for a user to place paper into the override tray (the printer is in use by a number of users). This anomaly does not happen with snp reports sent from other users, only from the two who are using one particular printer as their default printer.  As this relates to a remote customer, I have not so far requested the [affecting] sender users try using a different printer.  Either way it causes someone to perform extra steps -- Sender: if the printer selection was to be changed each time a snp report is created; Recipient: each time they need to print the particular report they need to go into printer options and override the Heavy Paper issue by selecting letter paper (and always be alert that the particular report came from the two particular sender users -- whereas once the recipient user sends the print job, it's too late; they need to run over to the printer to insert paper into the override tray to avoid a backlog of printer jobs). The site's IS team has bee

Unable to export data to an excel file in grid format!!!

I'm exporting data to an excel sheet from the ojects list. The data is exporting to excel sheet well, but I'm unable to see the grid format for the data. The data is looking with out the rows and columns lines. I think I'm missing to set some property or somethnig ehwn exporting.   Any help would be really appriciated.

how to change button backcolor property on a form from a class file


Hello friends,

I am having a problem of updating the main form button backcolor property from another class. I have attahced the code. Please tell how can i rectify this problem.

PopUp is another class, in which i want that when ToolStripDropDown closes it change the form button BackColor from Orange to WhiteSmoke.


public partial class PopUp : ToolStripDropDown


        public PopUp()





        protected override void OnClosed(ToolStripDropDownClosedEventArgs e)


               Form1 f1 = new Form1();

              // f1._pushed = false;

       f1.Controls["button1"].BackColor = Color.WhiteSmoke;





It seems that this line works, i checked it using MessageBox it changes the backcolor property but it does not updated to the form displayed on the screen. 

Can anyone help me

catch the html button click event on a class file including html text box value.


I want to catch the html button click event on a class file including html text box value..

<p><input name="" type="text"  value="Enter Name*"/></p>
<p><input name="" type="text"  value="Enter Email*"/></p>

  <input name="Input" type="submit" value="Submit" />

plz tell me how can i do this..

Which class to use for text file IO?



I'm trying to develop a project that will read a text file with variable length text records up to 900 bytes on each line.  Each line can be from 2 to 900 characters terminated by a CRLF.

My purpose is to read the text file into some kind of table and then send text and TIFF image documents to the printer based the contents of the text file.

I want to develop this project in .NET using VS2010 Pro.  I have VS 6.0 to VS2010.

My head is spinning after reading about the different ways i can read in the text file.  I need help determining which of these classes is most approppriate to use to accomplish the task.


Any help would be gratefully appreciated.


Stop The World, I want To Get Off!

XML File Format...


XML structure:


i have try to made quiz application using xml file

Requirement of Quiz:
1)question id
3)answers (radio button or checkbox)
6)next question where to go...?

my xml flie : sample.xml

suppose start application:
 show question id:1
 Show question   :what is your name?
 Show answers RB :1)Jhon
show flags:
           flag depends on section of answer mode if select 3)Lina show flag :Manager

if select other answer thete is no flags .

note shows:
        Note also depend on answer selction mode if select 4)ron do not showw flag show only note: i will add position.        

if select other answer thete is no Note.

next question:
        next question is also depend on answer if selct answer 1)jhon then go to directly question no. 5

Using a shared Class file with InfoPath 2007


I'm a total newbie to InfoPath 2007 Forms development which should be evident by the question that follows.

I'd like to create a file containing common functions that any developer here can add to their InfoPath 2007 code behind with a using statement. I'm not sure where this file would be stored. We publish our forms to a SharePoint library. I have written these in asp.net but am not sure how to get started with this in InfoPath development. Could anyone here give me some direction o nthis?



Multiple File Upload Class


I'm using this example here:


And have added some GUID for unique filenames.

I'm in the middle of trying to get the 3 filenames as strings and thought I'd put it in an external class file, but when I build the page:

public class MultipleFileUploader
    public static Boolean doMultipleFileUploader(string sFileUpload01,
        string sFileUpload02, string sFileUpload03)
        HttpFileCollection uploadedFiles = Request.Files;
        string sFileGuid = System.Guid.NewGuid().ToString();
        for (int i = 0; i < uploadedFiles.Count; i++)
            HttpPostedFile userPostedFile = uploadedFiles[i];
                if (userPostedFile.ContentLength > 0)
                    string serverFileName = Path.GetFileName(userPostedFile.FileName);
                    string getFileExtension = Path.GetExtension(serverFileName);//get the file extension
                    string sSaveLocation = Server.MapPath(sFilePath + "/") + sFileGuid + getFileExtension;
                    string sFileName = sFileGuid + serverFileName;
                    string FinalFileName = sFileGuid + getFileExtension;

Format File


Dear buddies,

I need to create a format file for many of my tables in SQL Server.

My objective is to create a fixed length text file. 

Could someone please guide me.


I am reading through msdn's docs on format file but I couldn't grasp it. Can I use bcp to create this? I will have to repeat this for many more tables.


Please guide me.


Thanks in advance.

Load XML data (string format - not file) into a gridview




 I need some help help loading some XML tagged data I received as a reply from a Web Service (String format), into individual fields on the web form.


After spending some time,  I was able to load an XML file into a gridview using this code...

<?xml version="1.0" encoding="ISO-8859-1"?>
        <title>Empire Burlesque</title>
        <artist>Bob Dylan</artist>
        <title>Hide your heart</title>
        <artist>Bonnie Tyler</artist>
        <company>CBS Records</company>

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