Wednesday, August 17, 2011

How to Read XML Value Using Linq

XDocument xmlDoc = XDocument.Load(Server.MapPath("../App_Code/" + "ReportReady.xml"));
var persons = from ReportSendSMS in xmlDoc.Descendants("Message")
                              select new
                              {
                                  Content = ReportSendSMS.Element("content").Value,
                              };

                string _Message = "";
                foreach (var person in persons)
                {
                    _Message = person.Content.ToString();
                }

String Replace With Multiple Char

using System.Text.RegularExpressions;

_Message = Regex.Replace(_Message, @"[\n\t ]", String.Empty);

Thursday, July 28, 2011

String Split Multiple Char or A or B Conditon

char[] delimiters = new char[] { '/', '-' };
                        string[] _DateTimeSplit = Request.QueryString["StudyDate"].ToString().Split(' ');
                        string[] _Date = _DateTimeSplit[0].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                        string _SDate = _Date[1] + "/" + _Date[0] + "/" + _Date[2] + " " + _DateTimeSplit[1];
                        _StudyDate = Convert.ToDateTime(_SDate);

Wednesday, June 8, 2011

How to Check string is Number or String

using System.Text.RegularExpressions;
 public bool IsNumeric(String strVal)
    {
        Regex reg = new Regex("[^0-9-]");
        Regex reg2 = new Regex("^-[0-9]+$|^[0-9]+$");
        return (!reg.IsMatch(strVal) && reg2.IsMatch(strVal));
    }

Bookmark Using Webconfig

Add This in Webconfig:

<add key="Bookmark" value="http://www.yahoo.com%5ewww.google.com%5ewww.facebook.com%22/>
<add key="Title" value="Yahoo^Google^Facebook"/>


Script Add This where you want:

<script type="text/javascript">
    function click_handler(sender, e) {
        if (e.get_item().get_commandName() == 'Bookmark') {
            var Url = '<%=ConfigurationManager.AppSettings["Bookmark"].ToString() %>'
            var Title = '<%=ConfigurationManager.AppSettings["Title"].ToString() %>'
            var UrlArry = Url.split('^');
            var TitleArry = Title.split('^');
            for (var i = 0; i < UrlArry.length; i++) {
                    bookmark_us(UrlArry[i], TitleArry[i]);
            }
        }
    }
    function bookmark_us(url, title) {
        if (window.sidebar) // firefox
            window.sidebar.addPanel(title, url, "");
        else if (window.opera && window.print) { // opera
            var elem = document.createElement('a');
            elem.setAttribute('href', url);
            elem.setAttribute('title', title);
            elem.setAttribute('rel', 'sidebar');
            elem.click();
        }
        else if (document.all)// ie
            window.external.AddFavorite(url, title);
    }
    
</script>

Monday, May 2, 2011

Table Cell Declaration in Code Page


TableRow row = new TableRow();
                    TableCell C1 = new TableCell();
                    TableCell C2 = new TableCell();
                    TableCell C3 = new TableCell();
                    TableCell C4 = new TableCell();
                    TableCell C5 = new TableCell();
                    TableCell C6 = new TableCell();


                    C1.Attributes.Add("valign", "top");
                    C1.Attributes.Add("align", "center");
                    C1.Text = Convert.ToString(i + 1);


                    C2.Attributes.Add("valign", "top");
                    C2.Attributes.Add("align", "left");
                    C2.Text = Convert.ToString(dsPatinetInfo.Tables[0].Rows[i]["ModalityName"]);

                    C3.Attributes.Add("valign", "top");
                    C3.Attributes.Add("align", "left");                  
                    C3.Text = Convert.ToString(dsPatinetInfo.Tables[0].Rows[i]["BillingName"]);

                    C4.Attributes.Add("valign", "top");
                    C4.Attributes.Add("align", "left");
                    C4.Font.Name = "3 of 9 Barcode";
                    C4.Attributes.Add("style", "font-size: 16px;");
                    C4.Text = Convert.ToString(dsPatinetInfo.Tables[0].Rows[i]["AccessionNumber"]);

                    C5.Attributes.Add("valign", "top");
                    C5.Attributes.Add("align", "left");

                    C6.Attributes.Add("valign", "top");
                    C6.Attributes.Add("align", "left");                                      

                    row.Cells.Add(C1);
                    row.Cells.Add(C2);
                    row.Cells.Add(C3);
                    row.Cells.Add(C4);
                    row.Cells.Add(C5);
                    row.Cells.Add(C6);

                    StudyTable.Rows.Add(row);