System.Text.RegularExpressions.MatchCollection mc = reg.Matches(sFileContents);
//string array for stroing System.Collections.Generic.List str = new System.Collections.Generic.List();foreach (System.Text.RegularExpressions.Match m in mc)
{
str.Add(m.Value);
}
OR
Second Method:
using System.Text.RegularExpressions; using System.IO;
try { //the file is in the root - you may need to change it string filePath = MapPath("~") + "/EmailText.txt";
using (StreamReader sr = new StreamReader( filePath) ) { string content = sr.ReadToEnd(); if (content.Length > 0) { //this pattern is taken from Asp.Net regular expression validators library string pattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"; MatchCollection mc = Regex.Matches(content, pattern); for (int i = 0; i <>
In my web form, I want to store multiple IDs inside an arraylist and then store the arraylist in a Session Variable (e.g. Session["InstallationID"]) to use it in a different web form where I want to use every ID inside the arraylist.
How do I place the arraylist inside the Session Variable and then take each ID off of it to be used in a SELECT statement?
Maintain Scroll Position after Asynchronous Postback
Do you want to maintain the scroll position of a GridView, Div, Panel, or whatever that is inside of an UpdatePanel after an asynchronous postback? Normally, if the updatepanel posts back, the item will scroll back to the top because it has been reloaded. What you need to do is “remember” where the item was scrolled to and jump back to there after the postback. Place the following script after the ScriptManager on your page. And since the _endRequest event of the PageRequestManager happens before the page is rendered, you’ll never even see your item move!
<script type="text/javascript"> var xPos, yPos; var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_beginRequest(BeginRequestHandler); prm.add_endRequest(EndRequestHandler); function BeginRequestHandler(sender, args) { xPos = $get('scrollDiv').scrollLeft; yPos = $get('scrollDiv').scrollTop; } function EndRequestHandler(sender, args) { $get('scrollDiv').scrollLeft = xPos; $get('scrollDiv').scrollTop = yPos; } </script>
In this tutorial, we'll create a class with a static function that returns true if connected and false if not, using our API function in private state.
Check this out :
using System ; using System.Runtime ; using System.Runtime.InteropServices ;
public class InternetCS {
//Creating the extern function... [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ;
//Creating a function that uses the API function... public static bool IsConnectedToInternet( ) {
int Desc ; return InternetGetConnectedState( out Desc, 0 ) ;
We cannot get the value of the checkbox in the checkboxlist because it is rendered in the form of table , td, input and the text of the check is like label.
So we need to bind the value of checkbox in the tilte attribute and then we can read the title values using javascript.
<scripttype="text/javascript">
function IsCheck()
{
var UserID="";
var UserCode=""
var cblist = "ChkBoxListUsers";
var chkList1= document.getElementById(cblist);
var arrayOfCheckBoxes= chkList1.getElementsByTagName("input");
var arrayOfCheckBoxspans= chkList1.getElementsByTagName("span");
var arrayOfCheckBoxLabels= chkList1.getElementsByTagName("label");