473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

whre can i write n store this code.which file i can use?

4 New Member
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Security.Permissions;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8.  
  9. namespace Samples.AspNet.Controls.CS {
  10.  
  11.     [AspNetHostingPermission(SecurityAction.Demand, 
  12.         Level=AspNetHostingPermissionLevel.Minimal)]
  13.     [AspNetHostingPermission(SecurityAction.InheritanceDemand, 
  14.         Level=AspNetHostingPermissionLevel.Minimal)]
  15.     public class TextBoxSet : DataBoundControl {
  16.  
  17.         private IList alBoxSet;
  18.         public IList BoxSet {
  19.             get {
  20.                 if (null == alBoxSet) {
  21.                      alBoxSet = new ArrayList();
  22.                 }
  23.                 return alBoxSet;                
  24.             }                    
  25.         }
  26.         public string DataTextField {
  27.             get {
  28.                 object o = ViewState["DataTextField"];
  29.                 return((o == null) ? string.Empty : (string)o);
  30.             }
  31.             set {
  32.                 ViewState["DataTextField"] = value;
  33.                 if (Initialized) {
  34.                     OnDataPropertyChanged();
  35.                 }
  36.             }
  37.         }
  38.         protected override void PerformSelect() {            
  39.  
  40.            // Call OnDataBinding here if bound to a data source using the
  41.            // DataSource property (instead of a DataSourceID), because the
  42.            // databinding statement is evaluated before the call to GetData.       
  43.             if (! IsBoundUsingDataSourceID) {
  44.                 OnDataBinding(EventArgs.Empty);
  45.             }            
  46.  
  47.             // The GetData method retrieves the DataSourceView object from  
  48.             // the IDataSource associated with the data-bound control.            
  49.             GetData().Select(CreateDataSourceSelectArguments(), 
  50.                 OnDataSourceViewSelectCallback);
  51.  
  52.             // The PerformDataBinding method has completed.
  53.             RequiresDataBinding = false;
  54.             MarkAsDataBound();
  55.  
  56.             // Raise the DataBound event.
  57.             OnDataBound(EventArgs.Empty);
  58.         }
  59.         private void OnDataSourceViewSelectCallback(IEnumerable retrievedData) {
  60.  
  61.            // Call OnDataBinding only if it has not already been 
  62.            // called in the PerformSelect method.
  63.             if (IsBoundUsingDataSourceID) {
  64.                 OnDataBinding(EventArgs.Empty);
  65.             }
  66.             // The PerformDataBinding method binds the data in the  
  67.             // retrievedData collection to elements of the data-bound control.
  68.             PerformDataBinding(retrievedData);                                    
  69.         }
  70.         protected override void PerformDataBinding(IEnumerable retrievedData) {
  71.             base.PerformDataBinding(retrievedData);
  72.  
  73.             // If the data is retrieved from an IDataSource as an 
  74.             // IEnumerable collection, attempt to bind its values to a 
  75.             // set of TextBox controls.
  76.             if (retrievedData != null) {
  77.  
  78.                 foreach (object dataItem in retrievedData) {
  79.  
  80.                     TextBox box = new TextBox();
  81.  
  82.                     // The dataItem is not just a string, but potentially
  83.                     // a System.Data.DataRowView or some other container. 
  84.                     // If DataTextField is set, use it to determine which 
  85.                     // field to render. Otherwise, use the first field.                    
  86.                     if (DataTextField.Length > 0) {
  87.                         box.Text = DataBinder.GetPropertyValue(dataItem, 
  88.                             DataTextField, null);
  89.                     }
  90.                     else {
  91.                         PropertyDescriptorCollection props = 
  92.                             TypeDescriptor.GetProperties(dataItem);
  93.  
  94.                         // Set the "default" value of the TextBox.
  95.                         box.Text = String.Empty;
  96.  
  97.                         // Set the true data-bound value of the TextBox,
  98.                         // if possible.
  99.                         if (props.Count >= 1) {                        
  100.                             if (null != props[0].GetValue(dataItem)) {
  101.                                 box.Text = props[0].GetValue(dataItem).ToString();
  102.                             }
  103.                         }
  104.                     }                                        
  105.  
  106.                     BoxSet.Add(box);
  107.                 }
  108.             }
  109.         }
  110.         protected override void Render(HtmlTextWriter writer) {
  111.  
  112.             // Render nothing if the control is empty.            
  113.             if (BoxSet.Count <= 0) {
  114.                 return;
  115.             }
  116.  
  117.             // Make sure the control is declared in a form tag 
  118.             // with runat=server.
  119.             if (Page != null) {
  120.                 Page.VerifyRenderingInServerForm(this);
  121.             }
  122.  
  123.             // For this example, render the BoxSet as 
  124.             // an unordered list of TextBox controls.            
  125.             writer.RenderBeginTag(HtmlTextWriterTag.Ul);
  126.  
  127.             foreach (object item in BoxSet) {
  128.  
  129.                 TextBox box = (TextBox) item;
  130.  
  131.                 // Write each element as 
  132.                 // <li><input type="text" value="string"><input/></li>
  133.  
  134.                 writer.WriteBeginTag("li");
  135.                 writer.Write(">");
  136.                 writer.WriteBeginTag("input");
  137.                 writer.WriteAttribute("type", "text");
  138.                 writer.WriteAttribute("value", box.Text);
  139.                 writer.Write(">");
  140.                 writer.WriteEndTag("input");
  141.                 writer.WriteEndTag("li");
  142.             }            
  143.  
  144.             writer.RenderEndTag();                       
  145.         }
  146.     }
Oct 7 '08 #1
1 1382
Curtis Rutland
3,256 Recognized Expert Specialist
What is your question? You can't just dump a block of code on us and expect us to tell you what to do with it.

Be very specific in your explanation.

Also, you need to use [code] tags when you post code.

MODERATOR
Oct 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
8747
by: Sowen | last post by:
Hi, all I am wondering how to write bits by using ofstream? I have finished a huffman tree, but how can I write the bits to the file in order to gain compression? for example, 'A' returns a code '1101', what I should write? 13? no, I don't think so
1
4311
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each time after routine process A, the text file is named "mytext.dat" in following format with "#####" as separator. The maximum entries of them is 5. When reaching the fifth entry, it will delete the very first entry.
6
17269
by: wiso | last post by:
My problem is this (from: http://www.cplusplus.com/ref/iostream/fstream/open.html) #include <fstream> using namespace std; int main() { fstream f;
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14061
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
6
5246
by: aagarwal8 | last post by:
Hi, I am trying to write the contents of a textbox to a file in binary format. My code looks like this... private void btnWriteToFile_Click(object sender, EventArgs e) { FileStream fs = File.Open(@"D:\test.dat", FileMode.OpenOrCreate, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs);
1
3930
by: Sachin Garg | last post by:
I have a program which opens a fstream in binary input+output mode, creating the file if it doesn't exists. But writing doesn't works after reading, it must be something obvious that I am not aware of. f.open(filename,ios::in | ios::out | ios::binary | ios::trunc) The program flow is 1) write some data 2) read the data
1
1189
by: sivakrishna546 | last post by:
hi all i am new to asp.net. i dont know whre to write a code for a new namespace? i want declare a new namespace n use it in another program? can anybody tell me .
8
28385
blazedaces
by: blazedaces | last post by:
So I have a program below which writes an excel file with multiple sheets based on inputs of sheet names, data, cell types, etc. It uses Apache POI, which is currently the only thing I found (correct me if I'm wrong about this) that can write excel 2007 files. The program works. I've tested it out on very small files (I will include the commented out main method that you can use to test this out yourself if you'd like, that is assuming you...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.