Convert a Dictionary to string of url parameters?

One approach would be: var url = string.Format(“http://www.yoursite.com?{0}”, HttpUtility.UrlEncode(string.Join(“&”, parameters.Select(kvp => string.Format(“{0}={1}”, kvp.Key, kvp.Value))))); You could also use string interpolation as introduced in C#6: var url = $”http://www.yoursite.com?{HttpUtility.UrlEncode(string.Join(“&”, parameters.Select(kvp => $”{kvp.Key}={kvp.Value}”)))}”; And you could get rid of the UrlEncode if you don’t need it, I just added it for completeness.

submit disabled fields

You can make your fields readonly, this will disallow changes to the value of your controls. Edit: You could easily write a “serializeDisabled” function, iterating over the disabled form elements which have a name attribute and using the jQuery.param function at the end, to generate the serialized string: (function ($) { $.fn.serializeDisabled = function () … Read more

LINQ: Get all selected values of a CheckBoxList using a Lambda expression

You are using lambda expressions – they are just concealed by your use of C#’s query operators. Consider that this: IEnumerable<int> allChecked = (from item in chkBoxList.Items.Cast<ListItem>() where item.Selected select int.Parse(item.Value)); Gets compiled to this: IEnumerable<int> allChecked = chkBoxList.Items.Cast<ListItem>() .Where(i => i.Selected) .Select(i => int.Parse(i.Value)); As you can see you are already using two lambda … Read more

DropDownList AppendDataBoundItems (first item to be blank and no duplicates)

Instead of using AppendDataboundItems=”true” (which will cause the problem you are talking about), respond to the DataBound event for the DropDownList and then add your “blank” item to the top of the list. <asp:DropDownList runat=”server” ID=”MyList” ondatabound=”MyListDataBound”></asp:DropDownList> Then in your code behind: protected void MyListDataBound(object sender, EventArgs e) { MyList.Items.Insert(0, new ListItem(“- Select -“, “”)); … Read more

Bundling resources via bundle.config vs BundleConfig.cs in ASP.NET 4.5 WebForms

As far as I can tell, the accepted answer doesn’t actually answer the question at all. It discusses the benefits of the bundling framework, but not how using the BundleConfig.cs is different than using the bundle.config file. A lot of it comes down to whether you prefer working in code or in markup, but each … Read more

If statements in aspx files

Since you have two controls on the page it will render them both. The if-check you create, only determines whether it’s included in the output. The easiest way to prevent this is to change your code like this: <div> <units:MyUserControl runat=”server” SomeSetting=”<%= Something %>” /> </div> EDIT: Answer to edit in the original post: <div> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)