The following code tell your how to read file(s):
Add main namespace for this operation
using System.IO;
Read html file
string file = Server.MapPath ("abc.html");
StreamReader sr;
FileInfo fi = new FileInfo(file);
string input = "";
if( File.Exists(file) )
{
sr = File.OpenText(file);
input += Server.HtmlEncode( sr.ReadToEnd() );
sr.Close();
}
input += "";
Label1.Text = input;
Read text file
StreamReader sr = File.OpenText(Server.MapPath("abc.txt"));
string strContents = sr.ReadToEnd();
//To display normal raw contentsResponse.Write(strContents);
//To handle Carriage returnsResponse.Write(strContents.Replace("\n" , ""));
sr.Close();
Thanks and Regards
Varun Bansal
Assitant Programmer
NIC, Jaipur
Tuesday, June 30, 2009
Add selected item from dropdownlist to listbox using javascript
This sample code snippet shows how to add selected item of dropdownlist into listbox using javascript.
On Default.aspx Page
< script language="javascript" type="text/javascript">
function itemsadd()
{
var myForm = document.Form1;
//Form Namevar mylist = myForm.listbox1;
// Listbox Name var myOpt;
myOpt = document.createElement("Option");
if(document.getElementById("ddl1").selectedIndex > 0)
{
myOpt.text = document.getElementById("ddl1").value;
//text of dropdownlistmyOpt.value = document.getElementById("ddl1").selectedIndex;
//index value of dropdownlistmylist.add(myOption);
add item of dropdown list into listbox
}
</script>
On Default.aspx.cs Page:
page_load()
{
ddl1.attributes.add("OnChange","itemsadd");
}
Thanks and Regards
Varun Bansal
Assitant Programmer
NIC, Jaipur
Subscribe to:
Posts (Atom)