<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-21511956</id><updated>2024-10-24T23:15:18.190+08:00</updated><category term="ASP.NET"/><category term="C#"/><category term="wss"/><category term="2.0"/><category term="ASP.NET)"/><category term="IE"/><category term="LIKE"/><category term="MSSQL"/><category term="asp.net 2.0"/><category term="button"/><category term="capitalize first letter"/><category term="checkboxlist"/><category term="data access"/><category term="databinding"/><category term="ispostback"/><category term="keyword search"/><category term="load from server"/><category term="new line"/><category term="next"/><category term="operator"/><category term="parameter"/><category term="partially works (C#"/><category term="previous"/><category term="retrieve IP"/><category term="sbs"/><category term="search service"/><category term="select"/><category term="sharepoint"/><category term="small business server"/><category term="stop cache"/><category term="string.format"/><category term="titlecase"/><category term="vs2005 express"/><category term="wcf data service cross domain policy telerik orm service odata v3"/><category term="zip"/><title type='text'>SF&#39;s Blog</title><subtitle type='html'>Achievement provides the only real pleasure in life</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>309</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-21511956.post-5919413201050554687</id><published>2016-12-25T18:32:00.003+08:00</published><updated>2016-12-25T18:33:02.001+08:00</updated><title type='text'>c# find number of occurance of substring in string</title><content type='html'>&lt;blockquote class=&quot;tr_bq&quot;&gt;
Regex.Matches(inputstring, substring).Count&lt;/blockquote&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/5919413201050554687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/5919413201050554687?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5919413201050554687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5919413201050554687'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2016/12/c-find-number-of-occurance-of-substring.html' title='c# find number of occurance of substring in string'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/01490690070051797761</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-9138349804349671823</id><published>2016-12-12T23:56:00.003+08:00</published><updated>2016-12-12T23:56:37.567+08:00</updated><title type='text'>.net mvc code first database migration configuration seed method error debugging</title><content type='html'>add the following code into the constructor of the method Configuration:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
if (System.Diagnostics.Debugger.IsAttached == false)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.Diagnostics.Debugger.Launch();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/blockquote&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/9138349804349671823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/9138349804349671823?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/9138349804349671823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/9138349804349671823'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2016/12/net-mvc-code-first-database-migration.html' title='.net mvc code first database migration configuration seed method error debugging'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-5078296970200196582</id><published>2016-01-12T08:28:00.002+08:00</published><updated>2016-01-12T08:28:20.641+08:00</updated><title type='text'>mvc 5 bootstrap datetimepicker incorrect display</title><content type='html'>when setup datetime display format in javascript it displays datetime value incorrectly, the following are what I have done to ensure my datetime value is displayed correctly&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;in my javascript I have&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;$(&#39;.dtpicker&#39;).datetimepicker({&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; format: &#39;YYYY/MM/DD HH:mm&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;in my model I have a property&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;[Display(Name = &quot;Paid Time&quot;)]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;[DisplayFormat(DataFormatString = &quot;{0:yyyy/MM/dd HH:mm}&quot;)]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;public DateTime PaidDateTimeLocal { get; set; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;in my view I make sure the datetime format is reinforced&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;@Html.TextBoxFor(model =&amp;gt; model.PaidDateTimeLocal, new { Value = Model.PaidDateTimeLocal.ToString(&quot;yyyy/MM/dd HH:mm&quot;), @class = &quot;dtpicker&quot; })&lt;/span&gt;&lt;br /&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/5078296970200196582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/5078296970200196582?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5078296970200196582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5078296970200196582'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2016/01/mvc-5-bootstrap-datetimepicker.html' title='mvc 5 bootstrap datetimepicker incorrect display'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-5048383046608644980</id><published>2015-12-26T21:49:00.003+08:00</published><updated>2015-12-27T14:17:30.426+08:00</updated><title type='text'>MVC 5 Code First ApplicationDbContext throws error</title><content type='html'>In my MVC 5 Code First project I decided to put my domain tables under the out of box ApplicationDbContext&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
When I run the command &quot;update-database ...&quot; I got this error:&lt;/div&gt;
&lt;div&gt;
&quot;&lt;span style=&quot;background-color: #fafafa; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Introducing FOREIGN KEY constraint &#39;FK_dbo.aaa_dbo.bbb_abcId&#39; on table &#39;aaa&#39; may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. See previous errors.&lt;/span&gt;&lt;/span&gt;&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
This is because I had not null 2 foreign keys in same table that both reference the primary key in same parent table. This creates 2 conflicting cascade delete paths. The solution is to make one of them nullable. See the source link:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://support.microsoft.com/en-us/kb/321843&quot;&gt;https://support.microsoft.com/en-us/kb/321843&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/5048383046608644980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/5048383046608644980?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5048383046608644980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5048383046608644980'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2015/12/mvc-5-code-first-applicationdbcontext.html' title='MVC 5 Code First ApplicationDbContext throws error'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-90026916402821283</id><published>2015-12-25T18:30:00.000+08:00</published><updated>2015-12-25T18:30:17.964+08:00</updated><title type='text'>mvc code first add foreign key referencing Asp.Net Identity ApplicationUser</title><content type='html'>in my case I have my own dbcontext called MyContext.&lt;br /&gt;
&lt;br /&gt;
1. in the child class MyModel add:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
public ApplicationUser User { get; set; }&lt;/blockquote&gt;
&lt;br /&gt;
2. in IdentityModels add below into class&amp;nbsp;ApplicationDbContext&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;protected override void OnModelCreating(DbModelBuilder modelBuilder)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; modelBuilder.Entity&lt;mymodel&gt;().HasRequired(MyModel&amp;nbsp;=&amp;gt;&amp;nbsp;MyModel.User);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; base.OnModelCreating(modelBuilder);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/mymodel&gt;&lt;/blockquote&gt;
&lt;br /&gt;
3. for some reason this is not enough, the same code in 2. needs to be add into my own dbcontext too. So in MyContext add below&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;protected override void OnModelCreating(DbModelBuilder modelBuilder)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; modelBuilder.Entity&lt;mymodel&gt;().HasRequired(MyModel&amp;nbsp;=&amp;gt;&amp;nbsp;MyModel.User);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; base.OnModelCreating(modelBuilder);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/mymodel&gt;&lt;/blockquote&gt;
&lt;br /&gt;
in database it correctly generates the foreign key relationship as:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CONSTRAINT [FK_dbo.UserProfiles_dbo.AspNetUsers_User_Id] FOREIGN KEY ([User_Id]) REFERENCES [dbo].[AspNetUsers] ([Id])&lt;/blockquote&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/90026916402821283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/90026916402821283?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/90026916402821283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/90026916402821283'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2015/12/mvc-code-first-add-foreign-key.html' title='mvc code first add foreign key referencing Asp.Net Identity ApplicationUser'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-7150469189317057404</id><published>2015-12-23T22:14:00.000+08:00</published><updated>2015-12-23T22:15:49.724+08:00</updated><title type='text'>Visual Studio  2015 Community MVC project could not open .cshtml views after installed github update</title><content type='html'>Visual Studio  2015 Community MVC project could not open .cshtml views after installed github update.
Lucky found the solution &lt;a href=&quot;https://github.com/aspnet/Tooling/issues/276&quot;&gt;here&amp;nbsp;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;


Step 1: remove everything under this folder
C:\Users\abc\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Step 2: reopen VS</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/7150469189317057404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/7150469189317057404?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/7150469189317057404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/7150469189317057404'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2015/12/visual-studio-2015-community-mvc.html' title='Visual Studio  2015 Community MVC project could not open .cshtml views after installed github update'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-2646196875594099503</id><published>2015-12-23T15:48:00.004+08:00</published><updated>2015-12-23T15:48:54.826+08:00</updated><title type='text'>TSQL: find out which table a constraint belongs to</title><content type='html'>TSQL: find out which table a constraint belongs to


&lt;pre&gt;

SELECT
   OBJECT_NAME(o.parent_object_id)
FROM
   sys.objects o
WHERE
   o.name = &#39;ConstraintABC&#39; AND o.parent_object_id &lt;&gt; 0

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/2646196875594099503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/2646196875594099503?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2646196875594099503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2646196875594099503'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2015/12/tsql-find-out-which-table-constraint.html' title='TSQL: find out which table a constraint belongs to'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-7946792599388635154</id><published>2015-08-28T09:04:00.004+08:00</published><updated>2015-08-28T09:04:53.214+08:00</updated><title type='text'>Google Chrome cannot connect to internet after upgrade from Windows 8.1 to Windows 10</title><content type='html'>
this solution worked for me (https://productforums.google.com/d/msg/chrome/ZE4c98nklAw/47xvIIz8zN8J)

1. run cmd as administrator
2. type in &quot;netsh winsock reset&quot;
3. restart pc</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/7946792599388635154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/7946792599388635154?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/7946792599388635154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/7946792599388635154'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2015/08/google-chrome-cannot-connect-to.html' title='Google Chrome cannot connect to internet after upgrade from Windows 8.1 to Windows 10'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-7745642960076582197</id><published>2014-08-19T22:50:00.004+08:00</published><updated>2014-08-19T22:50:54.425+08:00</updated><title type='text'>mvc checkboxlist</title><content type='html'>&lt;pre&gt;

//Set up a viewmodel MyViewModel to contain the following

        [DisplayName(&quot;Available Products&quot;)]
        public IList&lt;ProductDropdownItemViewModel&gt; AvailableProducts { get; set; }
        public IList&lt;ProductDropdownItemViewModel&gt; SelectedProducts { get; set; }

        public PostedProducts PostedProducts { get; set; }



//The definition of ProductDropdownItemViewModel and PostedProducts are:

    public class PostedProducts
    {
        public int[] ProductIds { get; set; }
    }

    public class ProductDropdownItemViewModel
    {
        public int Id { get; set; }
        public string Name { get; set; }        
    }


//In your controller method populate the above viewmodel

  e.g. 
                MyViewModel.AvailableProducts = db.Products
                .Select(p =&gt; new ProductDropdownItemViewModel 
            {
                Id = p.Id,
                Name = p.Name
            }).ToList();


//In your view display the checkbox list this way

  e.g. the postback method name is Edit

     @model MyViewModel
     @using (Html.BeginForm(&quot;Edit&quot;, FormMethod.Post, new { enctype = &quot;multipart/form-data&quot; }))
     {
        @Html.CheckBoxListFor(x =&gt; x.PostedProducts.ProductIds,
                      x =&gt; x.AvailableProducts,
                      x =&gt; x.Id,
                      x =&gt; x.Name,
                      x =&gt; x.SelectedProducts,
                      MvcCheckBoxList.Model.Position.Vertical)
     }


//In your postback method Edit use the following code to retrieve your selected items


       public ActionResult Edit(PostedProducts postedProducts)
       {

                foreach (var id in postedProducts.ProductIds)
                {
                     //do whatever you like with the selected product id
                }

       }

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/7745642960076582197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/7745642960076582197?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/7745642960076582197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/7745642960076582197'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/08/mvc-checkboxlist.html' title='mvc checkboxlist'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-8296221064718184356</id><published>2014-08-05T18:53:00.002+08:00</published><updated>2014-08-05T18:53:51.243+08:00</updated><title type='text'>tsql create table if not already exists</title><content type='html'>&lt;pre&gt;

IF  NOT EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N&#39;[dbo].[table1]&#39;) AND type in (N&#39;U&#39;))

BEGIN

CREATE TABLE [dbo].[table1](
 [Id] [int] IDENTITY(1,1) NOT NULL,
 [Name] [nvarchar](150) NOT NULL,
 CONSTRAINT [PK_abc] PRIMARY KEY CLUSTERED 
(
 [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]



END
go

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/8296221064718184356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/8296221064718184356?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/8296221064718184356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/8296221064718184356'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/08/tsql-create-table-if-not-already-exists.html' title='tsql create table if not already exists'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-3151888668224379902</id><published>2014-08-05T18:39:00.003+08:00</published><updated>2014-08-05T18:39:46.172+08:00</updated><title type='text'>c# read data from .xsl</title><content type='html'>&lt;pre&gt;

public void ReadExcel(HttpPostedFileBase file, string currentUserName)
        {

            DataTable tbContainer = new DataTable();
            string strConn = XlsConnectionString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; + file.FileName +&quot;;Extended Properties=&#39;Excel 8.0;HDR=Yes;IMEX=1;&#39;&quot;;
            string sheetName = &quot;sheet1&quot;;
            FileInfo fileInfo = new FileInfo(file.FileName);
            OleDbConnection cnnxls = new OleDbConnection(strConn);
            OleDbDataAdapter oda = new OleDbDataAdapter(string.Format(&quot;select * from [{0}$]&quot;, sheetName), cnnxls);
            DataSet ds = new DataSet();
            oda.Fill(tbContainer);
            var newParcelTubeExport = new ParcelTubeExport();

            //your code to utilize the data

         }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/3151888668224379902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/3151888668224379902?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/3151888668224379902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/3151888668224379902'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/08/c-read-data-from-xsl.html' title='c# read data from .xsl'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-2494749828474631149</id><published>2014-07-31T20:33:00.001+08:00</published><updated>2014-07-31T20:33:11.756+08:00</updated><title type='text'>javascript round decimal to preferred number of decimal places</title><content type='html'>&lt;pre&gt;
function round(value, decimals) {
    return Number(Math.round(value + &#39;e&#39; + decimals) + &#39;e-&#39; + decimals);
}

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/2494749828474631149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/2494749828474631149?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2494749828474631149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2494749828474631149'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/07/javascript-round-decimal-to-preferred.html' title='javascript round decimal to preferred number of decimal places'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-6133510516272124389</id><published>2014-07-31T20:32:00.001+08:00</published><updated>2014-07-31T21:16:27.905+08:00</updated><title type='text'>javascript validation for decimal(10,2)</title><content type='html'>&lt;pre&gt;
$(function () {
    $(&#39;.decimal10n2&#39;).keyup(function () {
        if (!$(this).val().match(/./gi) || !$(this).val().match(/[0-9]+/g)) {
            $(this).val(&quot;&quot;);
        }
        else if ($(this).val().split(&#39;.&#39;).length - 1 &gt; 1)
        {
            this.value = $(this).val().slice(0, -1);
        }
        else if ($(this).val().indexOf(&#39;.&#39;) != -1) {
            if($(this).val().split(&quot;.&quot;)[0].length &gt; 10)
            {
                if (isNaN(parseFloat(this.value))) return;
                this.value = $(this).val().split(&quot;.&quot;)[0].slice(0,-1);
            }
            else if ($(this).val().split(&quot;.&quot;)[1].length &gt; 2) {
                if (isNaN(parseFloat(this.value))) return;
                this.value = parseFloat(this.value).toFixed(2);
            }
        }

        return this;
    });
});


&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/6133510516272124389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/6133510516272124389?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/6133510516272124389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/6133510516272124389'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/07/javascript-validation-for-decimal102.html' title='javascript validation for decimal(10,2)'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-5615231923261992134</id><published>2014-04-29T22:58:00.002+08:00</published><updated>2014-04-29T22:58:41.421+08:00</updated><title type='text'>jquery close navigation submenu when click away</title><content type='html'>&lt;pre&gt;
$(document).ready(function () {
    $(&quot;.navbar-sub-opener&quot;).click(function (evt) {
        &lt;b&gt;//close submenu when click away - part 2&lt;/b&gt;
        evt.stopPropagation();
        //hide all submenus
        $(&quot;.navbar-sub&quot;).hide();
        //only open the one that&#39;s immediate inside the clicked parent menu item
        $(this).next($(&quot;.navbar-sub&quot;)).show();
    });

    &lt;b&gt;//close submenu when click away - part 1&lt;/b&gt;
    $(&#39;html&#39;).click(function () {
        $(&quot;.navbar-sub&quot;).hide();
    });
});
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/5615231923261992134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/5615231923261992134?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5615231923261992134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5615231923261992134'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/04/jquery-close-navigation-submenu-when.html' title='jquery close navigation submenu when click away'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-825225626123784402</id><published>2014-04-10T00:55:00.001+08:00</published><updated>2014-04-10T00:55:37.994+08:00</updated><title type='text'>jquery center div</title><content type='html'>

&lt;pre&gt;

jQuery.fn.center = function () {
    this.css(&quot;position&quot;, &quot;fixed&quot;);
    this.css(&quot;top&quot;, ($(window).height() / 2) - (this.outerHeight() / 2));
    this.css(&quot;left&quot;, ($(window).width() / 2) - (this.outerWidth() / 2));
    return this;
}

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/825225626123784402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/825225626123784402?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/825225626123784402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/825225626123784402'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/04/jquery-center-div.html' title='jquery center div'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-114924539684834509</id><published>2014-04-02T03:41:00.001+08:00</published><updated>2014-04-02T18:08:56.218+08:00</updated><title type='text'>mvc partial view popup dialog form</title><content type='html'>&lt;b&gt;required javascript:&lt;/b&gt;

&lt;pre&gt;
$(document).ready(function () {
    $(&quot;.popupformContainer&quot;).dialog({
        height: 600,
        width: 300,
        autoOpen: false,
        modal: true,
        open: function (event, ui) {
            $(this).load(&quot;/controllername/actionname&quot;, { &quot;parameter&quot;: $(this).data(&quot;parametervalue&quot;) }, function (html) {
            });
        },
        close: function (event, ui) {
            event.preventDefault();
            alert(&quot;closing&quot;);
        },
        buttons: {
            text: &quot;提交&quot;, click: function (event) {
                event.preventDefault();
                $.validator.unobtrusive.parse(&quot;#PopupForm&quot;);
                $(&quot;#PopupForm&quot;).validate();
                if ($(&quot;#PopupForm&quot;).valid()) {
                    $(&quot;#PopupForm&quot;).submit();
                }
                else {
                    event.preventDefault();
                    alert(&quot;invalid&quot;);
                }
            }
        }
    });

    $(&quot;.btnOpenPopupForm&quot;).click(function () {
        $(&quot;.popupformContainer&quot;).data(&quot;parameter&quot;, $(this).attr(&quot;value&quot;)).dialog(&quot;open&quot;);
    });


});&lt;/pre&gt;

&lt;b&gt;in the parent view you need the button to open popup with class &quot;btnOpenPopupForm&quot; and an empty div with class &quot;popupformContainer&quot; for hosting the popup&lt;/b&gt;
&lt;br /&gt;

&lt;b&gt;in the partial view for the popup all you need is the form and all the form elements, the buttons are automatically generated unless you want some custom buttons&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/114924539684834509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/114924539684834509?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/114924539684834509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/114924539684834509'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/04/mvc-partial-view-popup-dialog-form.html' title='mvc partial view popup dialog form'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-25666357014025842</id><published>2014-03-27T01:54:00.001+08:00</published><updated>2014-03-27T01:54:44.657+08:00</updated><title type='text'>tsql where clause checking even or odd number</title><content type='html'>update student&lt;br /&gt;
set isOdd = 1, isEven = 0&lt;br /&gt;
where exammark % 2 =1&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/25666357014025842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/25666357014025842?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/25666357014025842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/25666357014025842'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/03/tsql-where-clause-checking-even-or-odd.html' title='tsql where clause checking even or odd number'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-8777406707799780926</id><published>2014-03-26T02:20:00.000+08:00</published><updated>2014-03-26T02:20:01.157+08:00</updated><title type='text'>asp.net mvc c# convert a virtual path to application absolute path</title><content type='html'>use UrlHelper WebViewPage.Url&lt;br /&gt;
&lt;div&gt;
e.g.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPfQIO33PR1SRdUn2tjdG7pF5rzIK9xl44JJGn1do0jEp2RDgYFUhQ7k9t5PU7IGkUv6IzoMThCHzJacIHpSpma7nzINyuShYZXUkDDO1ZpM8nRohWFeN5oHWRpkNTYYOngskngA/s1600/Capture.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPfQIO33PR1SRdUn2tjdG7pF5rzIK9xl44JJGn1do0jEp2RDgYFUhQ7k9t5PU7IGkUv6IzoMThCHzJacIHpSpma7nzINyuShYZXUkDDO1ZpM8nRohWFeN5oHWRpkNTYYOngskngA/s1600/Capture.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/8777406707799780926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/8777406707799780926?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/8777406707799780926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/8777406707799780926'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/03/aspnet-mvc-c-convert-virtual-path-to.html' title='asp.net mvc c# convert a virtual path to application absolute path'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPfQIO33PR1SRdUn2tjdG7pF5rzIK9xl44JJGn1do0jEp2RDgYFUhQ7k9t5PU7IGkUv6IzoMThCHzJacIHpSpma7nzINyuShYZXUkDDO1ZpM8nRohWFeN5oHWRpkNTYYOngskngA/s72-c/Capture.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-4262421591970592551</id><published>2014-03-10T00:14:00.002+08:00</published><updated>2014-03-10T00:14:53.202+08:00</updated><title type='text'>mvc refresh current view without losing stuff like sorting, filtering etc</title><content type='html'>return Redirect(Request.UrlReferrer.ToString());</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/4262421591970592551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/4262421591970592551?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/4262421591970592551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/4262421591970592551'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/03/mvc-refresh-current-view-without-losing.html' title='mvc refresh current view without losing stuff like sorting, filtering etc'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-2374746933997650457</id><published>2014-03-01T17:26:00.004+08:00</published><updated>2014-03-01T17:26:53.743+08:00</updated><title type='text'>mvc HttpPostedFileBase always null</title><content type='html'>make sure the form declaration in the view has all necessary attributes, e.g.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
@using (Html.BeginForm(&quot;Create&quot;, &quot;Product&quot;, FormMethod.Post, new { enctype = &quot;multipart/form-data&quot; }))&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/2374746933997650457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/2374746933997650457?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2374746933997650457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2374746933997650457'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/03/mvc-httppostedfilebase-always-null.html' title='mvc HttpPostedFileBase always null'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-5878607527558476868</id><published>2014-03-01T17:25:00.000+08:00</published><updated>2014-03-01T17:25:06.030+08:00</updated><title type='text'>found a useful way to show div as a modal</title><content type='html'>http://jsfiddle.net/r77K8/1/</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/5878607527558476868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/5878607527558476868?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5878607527558476868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5878607527558476868'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/03/found-useful-way-to-show-div-as-modal.html' title='found a useful way to show div as a modal'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-5181646095668407868</id><published>2014-02-28T17:28:00.001+08:00</published><updated>2014-02-28T17:28:29.959+08:00</updated><title type='text'>asp.net mvc c# upload image, generate and upload thumbnail</title><content type='html'>public void UploadProductImage(HttpPostedFileBase file)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string subPath = &quot;~/Images/&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bool isExists = System.IO.Directory.Exists(Server.MapPath(subPath));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!isExists)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.IO.Directory.CreateDirectory(Server.MapPath(subPath));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (file != null)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string pic = System.IO.Path.GetFileName(file.FileName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string path = System.IO.Path.Combine(Server.MapPath(subPath), pic);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file.SaveAs(path);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UploadProductImageThumbnail(file, productId);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public void UploadProductImageThumbnail(HttpPostedFileBase file)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var image = Image.FromStream(file.InputStream, true, true))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var thumbWidth = 50;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var thumbHeight = 50;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var thumb = image.GetThumbnailImage(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thumbWidth,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thumbHeight,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; () =&amp;gt; false,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IntPtr.Zero))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var jpgInfo = ImageCodecInfo.GetImageEncoders()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .Where(codecInfo =&amp;gt; codecInfo.MimeType == &quot;image/jpeg&quot;).First();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var encParams = new EncoderParameters(1))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string thumbPath = &quot;~/Images/Thumbnails&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bool isExists = System.IO.Directory.Exists(Server.MapPath(thumbPath));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!isExists)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.IO.Directory.CreateDirectory(Server.MapPath(thumbPath));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var thumbPathFull = Path.Combine(Server.MapPath(thumbPath), file.FileName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; long quality = 100;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encParams.Param[0] = new EncoderParameter(Encoder.Quality, quality);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thumb.Save(thumbPathFull, jpgInfo, encParams);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/5181646095668407868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/5181646095668407868?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5181646095668407868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/5181646095668407868'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/02/aspnet-mvc-c-upload-image-generate-and.html' title='asp.net mvc c# upload image, generate and upload thumbnail'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-3212292385830819721</id><published>2014-02-21T00:10:00.000+08:00</published><updated>2014-02-21T00:10:07.143+08:00</updated><title type='text'>linq compare int with string</title><content type='html'>&lt;pre style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;products&amp;nbsp;=&amp;nbsp;products.Where(p&amp;nbsp;=&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;SqlFunctions&lt;/span&gt;.StringConvert((&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;)p.ProductId).Trim()&amp;nbsp;==&amp;nbsp;searchString);&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/3212292385830819721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/3212292385830819721?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/3212292385830819721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/3212292385830819721'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2014/02/linq-compare-int-with-string.html' title='linq compare int with string'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-427274467034800458</id><published>2013-06-25T12:57:00.003+08:00</published><updated>2013-06-25T12:57:54.093+08:00</updated><title type='text'>RadGrid access the control inside command item template in DataBound event</title><content type='html'>protected void RadGrid1_DataBound(object sender, eventargs e)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;GridItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Button button1 = commandItem.FindControl(&quot;button1&quot;) as Button;&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/427274467034800458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/427274467034800458?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/427274467034800458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/427274467034800458'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2013/06/radgrid-access-control-inside-command.html' title='RadGrid access the control inside command item template in DataBound event'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21511956.post-2304692595494391039</id><published>2013-06-21T12:08:00.003+08:00</published><updated>2013-06-21T12:08:36.573+08:00</updated><title type='text'>the updated way to open radwindow from server side</title><content type='html'>string script = &quot;function f(){$find(\&quot;&quot; + RadWindow1.ClientID + &quot;\&quot;).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ScriptManager.RegisterStartupScript(this, this.GetType(), &quot;key&quot;, script, true);</content><link rel='replies' type='application/atom+xml' href='http://sssfffccc.blogspot.com/feeds/2304692595494391039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/21511956/2304692595494391039?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2304692595494391039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21511956/posts/default/2304692595494391039'/><link rel='alternate' type='text/html' href='http://sssfffccc.blogspot.com/2013/06/the-updated-way-to-open-radwindow-from.html' title='the updated way to open radwindow from server side'/><author><name>SF</name><uri>http://www.blogger.com/profile/02687285337008447790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>