RegisterStartupScript doesn’t work with ScriptManager,Updatepanel. Why is that?

When you use an UpdatePanel, then you can not call JavaScript using ClientScript as you have tried to. You have to use ScriptManager.RegisterStartupScript instead. So change your Page.ClientScript.RegisterStartupScript(this.GetType(), “myKey”, javaScript); to ScriptManager.RegisterStartupScript(updatePanelId,updatePanelId.GetType(), “alert”, javaScript, true);

Impersonate using Forms Authentication

Impersonating a user using Forms Authentication can be done. The following code does work. The Visual Studio Magazine article referred to by Robert is an excellent resource. There are a some issues with the example code in the article, so I’ve included some working code below. Note: If you are using Visual Studio, make sure … Read more

How to use the tag in ASP.NET?

I use <asp:Label … AssociatedControlID=”Username” …> controls for this. They get rendered as <label> tags and set the for attribute appropriately. Note that you can also nest other tags within the Label control if you wish: <asp:Label ID=”UsernameLabel” Text=”Username:” AssociatedControlID=”UsernameTextBox” runat=”server”> <asp:TextBox ID=”UsernameTextBox” runat=”server” /> </asp:Label>

How to disable caching of single page application HTML file served through IIS?

Adding the following into web.config solution worked across Chrome, IE, Firefox, and Safari: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <location path=”index.html”> <system.webServer> <httpProtocol> <customHeaders> <add name=”Cache-Control” value=”no-cache” /> </customHeaders> </httpProtocol> </system.webServer> </location> </configuration> This will ensure that the that Cache-Control header is set to no-cache when requesting index.html.

What is the difference between and ?

See also this question. MVC hasn’t changed how these bee-stings work, just how often they’re used. Basically: <% – execute code <%@ – page directive <%$ – resource access <%= – explicit output to page <%# – data binding <%– – server side comment block Also new in ASP.Net 4: <%: – writes out to … Read more

How to get POST data in WebAPI?

From answer in this question: How to get Json Post Values with asp.net webapi Autoparse using parameter binding; note that the dynamic is made up of JToken, hence the .Value accessor. public void Post([FromBody]dynamic value) { var x = value.var1.Value; // JToken } Read just like Request.RequestUri.ParseQueryString()[key] public async Task Post() { dynamic obj = … Read more