Skip to main content

Posts

Creating a HTML tag in C# Code (TEXT AREA) Asp.Net and display it in HTML Page

Follow @harshit_parshii HtmlTextWriter:-  The HtmlTextWriter class is used to render HTML 4.0 to desktop browsers. The HtmlTextWriter is also the base class for all markup writers in theSystem.Web.UI namespace. It Writes markup characters and text to an ASP.NET server control output stream. This class provides formatting capabilities that ASP.NET server controls use when rendering markup to clients. It allows you to generate a list of HTML elements, such as <div> elements. You could use StringBuilder to create the HTML, but HtmlTextWriter is sometimes better—fewer errors are likely. Below is sample code: protected void Page_Load(object sender, EventArgs e) {     TextBox txtBox = new TextBox();     // Initialize StringWriter instance.     StringWriter stringWriter = new StringWriter();     // Put HtmlTextWriter in using block because it needs to call Dispose.     using(HtmlTextWriter writer ...

Taking Backup of database in one server and restoring in other via sql commands

Database YourDB has full backup YourBaackUpFile.bak. It can be restored using following two steps. Step 1:  Retrive the Logical file name of the database from backup. RESTORE  FILELISTONLY  FROM DISK =  'D:BackUpYourBaackUpFile.bak' GO Step 2:  Use the values in the LogicalName Column in following Step. Step 2.1: ----Checking if the drive exist(for ldf n mdf files) in this particular server EXEC master.dbo.xp_fileexist 'YourLDFLogicalName'  EXEC master.dbo.xp_fileexist ' YourMDFLogicalName It will give 3 columns, for file, directory and root directory. Check if it exist or not for both LDF and MDF files. Step 2.2 ---If not then change the file path using these lines --For data file SELECT TOP 1 ms . physical_name FROM master . sys . master_files ms WHERE ms . file_id = 2 ORDER BY ms . database_id DESC --For log file SELECT TOP 1 ms . physical_name FROM master . sys . master_files ms WHERE m...

SQL Joins

Follow @harshit_parshii SQL JOIN The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. Tables in a database are often related to each other with keys. A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table FULL OUTER JOIN A JOIN is made matching a column on a table to a column on the other table. After a FULL OUTER JOIN, for a given value (red), for a given row with this value on one table ([ red | 9999 ]), one row is created for each row that matches on the other table ([ red | OOOOOO ] and [ red | LLLLLL ]). If a value exists in only one table, then a row is created and is completed with NULL columns. FROM table_1 FULL OUTER JOIN table_2 ON table_1...

Beginners Guide to File Handling in C#, .net

Make a new project in Visual Studio (Console App) Add a new .cs file named as MySetting.cs, in that file copy paste the following code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 using System ; using System.Collections.Generic ; using System.Linq ; using System.Text ;...

HTML and JavaScript Validated form (Simple and Easy)

Hi, In the following web form we have used a simple HTML table and Inline CSS styling, the validation is done via java-script, its vulnerable to threats coz anyone can copy your form from browser and send some idiotic data in it, but good for beginners, all we need is captcha in it to make it more effective. The submit button do nothing, it doesn't have any db call attached with it, so don't worry you can add as much dummy data in it to check the validations. I have taken almost all the required validation and you can take the native code by saving the web page, open it in notepad, search for 'A simple WEB form'. Enjoy...

Asynchronous Threading, First Code

Synchronous threading will execute each thread/command in the order they have been created/started Suppose there are 4 threads A, B, C, D Application Starts at 10:00:00 time: 10:00:00: -> Start thread A (will run for 5 seconds) time: 10:00:05: -> Start thread B (will run for 10 seconds) time: 10:00:15: -> Start Thread B1 (will run for 5 seconds) time: 10:00:20: -> Start thread C (will run for 15 seconds) end application: total run time will be 35 seconds Asynchronous threading will run the threads at the same time/ parallel processing, or we can say it will take the thread that is available at the earliest. Application Starts at 10:00:00 time: 10:00:00: -> Start thread A (will run for 5 seconds) / Start thread B (will run for 10 seconds) / Start thread C (will run for 15 seconds) time: 10:00:10: -> Start Thread B1 (will run for 5 seconds) end application: total run-time will be 15 seconds (because the longest run-time is thread C) So Async Threadi...

Stored Procedure

Introduction A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc , sproc , StoPro , StoredProc , sp or SP ) is actually stored in the database data dictionary. Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms . Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another. Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement. SQL Dialect...