webforms

How can I do a call back to the code behind method using javascript (properly)?

梦想的初衷 提交于 2021-02-11 12:49:01
问题 So I am trying to call back to a code behind method using Javascript and it seems like the only way to do so is using the Page.ClientScript.RegisterClientScriptBlock() Method. I don't need to return any data back to the calling javascript function. This isn't a web service, so I am not going to use a ajax call, but this seems like there would be an easier way to do this than Client Callbacks Programmatically with Page.ClientScript..... 回答1: Page.ClientScript.RegisterClientScriptBlock() is

Issue with Bundling and Release mode

末鹿安然 提交于 2021-02-11 10:55:35
问题 When ever i publish my web site with debug="false" mode and BundleTable.EnableOptimizations = true the server returns the following exception for bundled scripts and styles while requests are just for non authorized requests! But if I run application with debug="true" or user is logged in (via forms authentication in release mode) the exception does not occur and every thins works just fine. I think there should be a relation between bundling and authentication!! as the exception indicates.

Align textbox to right of radiobuttonlist listitem

家住魔仙堡 提交于 2021-02-10 06:43:31
问题 I'm trying to do a slight upgrade of a .NET WebForms page to Bootstrap 3. I need to maintain a feature that worked fine without Bootstrap. I need a small textbox to the right of a radio button label. Like, when selecting "Other" you need to free form text what other means. In the sample above, I just need the textbox to move up and not be as wide as the entire form. Here is my current code: <div class="form-group"> <asp:Label ID="Ethnicity_Label" runat="server" Text="Ethnicity" CssClass="col

How to update UI immediately when running an async task

亡梦爱人 提交于 2021-02-08 09:58:13
问题 I have an Asp.Net 4.5 webforms application with a report which I'm trying to run using async await. Here is an example of the code I'm using: protected async void btnReport_Click(object sender, EventArgs e) { lblStatus.Text = "Working!"; await LongRunningTask(); } private async Task LongRunningTask() { await Task.Delay(5000); lblStatus.Text = "Done!"; } Everything I've read seems to suggest that the first method should complete immediately and update the label but this is not the case. The

How to update UI immediately when running an async task

。_饼干妹妹 提交于 2021-02-08 09:57:52
问题 I have an Asp.Net 4.5 webforms application with a report which I'm trying to run using async await. Here is an example of the code I'm using: protected async void btnReport_Click(object sender, EventArgs e) { lblStatus.Text = "Working!"; await LongRunningTask(); } private async Task LongRunningTask() { await Task.Delay(5000); lblStatus.Text = "Done!"; } Everything I've read seems to suggest that the first method should complete immediately and update the label but this is not the case. The

ASP.NET CompareValidator issue

笑着哭i 提交于 2021-02-07 11:18:20
问题 I've got a web form with Password and Confirm Password text boxes. I've got a RegularExpressionValidator attached to the first one and CompareValidator to the second one. Now the problem is when i have something in the Password field and nothing in Confirm Password field it does not display an error that fields don't match. As soon as i put something in the Confirm Password field it shows the error. I also want to allow to leave both fields blank. I'm using .NET 2.0 What might it be? 回答1:

How to access my variables in a web method?

∥☆過路亽.° 提交于 2021-02-05 11:14:07
问题 I am using ASP.NET Webforms and in one page I want to make an AJAX call to a web method in the code behind. The problem is that web methods are static and I can't access page variables. I need to be able to have Ninject inject a dependency. Is there a way to do this in a web method? public partial class Default : Ninject.Web.PageBase { [Inject] public ISecurityController SecurityController { get; set; } [WebMethod] public static string DoSomething() { SecurityController.WriteToLog(); // Can't

asp.net Web Form custom error messages for each element

允我心安 提交于 2021-02-05 09:57:05
问题 I have created a web application - form, along with backend SQL insertions and queries. Currently I am displaying all user error messages:- <div style="padding: 1em;"> <asp:DataList ID="dtlERA_Errors" runat="server" Visible="false"> <ItemTemplate> - <asp:Label ID="Label4" runat="server" Text='<%#Eval("Description") %>'></asp:Label></ItemTemplate> </asp:DataList> </div> this div is at the bottom of my aspx page and it lists all errors in order. However my goal is to create custom error

Customize web form script generation

白昼怎懂夜的黑 提交于 2021-02-05 07:24:05
问题 Ok, yes, it's 2020 but don't laugh. I'm trying update some ASP.NET web forms. My goal is to lock them down, making them more secure by applying a more restrictive Content Security Policy (CSP). To that end, I'm using a nonce, rather than allowing unsafe-inline for scripting. For "simple" web forms, it's working fine. However, I hit a problem whenever there's an asp control that results in a post back. When I look in the page source, I see stuff like this: <script type="text/javascript"> //<!

DropDownList selected item always first item in list

一个人想着一个人 提交于 2021-02-05 07:00:38
问题 I have a DropDownList in a user control; however, no matter what I do I can't get any of the "selected" properties (SelectedItem, SelectedIndex, SelectedValue) to populate correctly. The value of all three of these properties is the first item in my list no matter which item was actually selected. <asp:DropDownList ID="ParticipantsSelectList" runat="server"> <asp:ListItem Value="">Please select a team...</asp:ListItem> <asp:ListItem value="{D37EFA0C-988A-4A2A-8D6E-80E3BAE00DEE}">Blue Team<