Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts

Saturday, April 15, 2017

Call JavaScript function from code behind

Example 1

Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","MyFunction()",true);

Example 2

ClientScript.RegisterStartupScript(GetType(),"hwa","alert('Hello World...');",true);

Tuesday, April 11, 2017

HTML NOSCRIPT TAG

HTML <noscript> tag define alternative content for those user who has disable JavaScript in their browser

And also for those user whose browser is not able to support JavaScript

Programmer can write code or message for these kind of user in between <noscript> and </noscript>

The <noscript> element can be used in both <head> and <body>

<noscript> tag is supported by all browser

Example

<noscript>
   Any HTML code here
</noscript>

Thursday, December 1, 2016

Get selected data from datatable in c#

Example
            string StudentName = "foo";
            DataTable dt = new DataTable();
            int id = (from DataRow dr in dt.Rows
                      where (string)dr["StudentName"] == StudentName
                      select (int)dr["id"]).FirstOrDefault();

Example

            DataRow[] result = datatable.Select("age >= 18");
            foreach (DataRow row in result)
            {
                Console.WriteLine("{0}, {1}", row[0], row[1]);
            }

Example
by LINQ
var results = from myRow in myDataTable.AsEnumerable()
where myRow.Field<int>("RowNo") == 1 select myRow;