webforms

Can Page_Load() Be Async

时光总嘲笑我的痴心妄想 提交于 2020-01-23 09:19:10
问题 Can a Page_Load() method be async ? I ask as if I have declared as such protected void Page_Load() Everything loads as it should. If I have it declared as such protected async void Page_Load() the Page_Load() breakpoint is not hit, nor does the catch() block get hit. Now I am trying to set my Page_Load() method as async in order to have 3 different stored procedures execute to completion before the page is fully rendered. If I do not have my Page_Load() method as async I get this compile

Pass parameter to Javascript function from ASP code behind

佐手、 提交于 2020-01-22 13:00:13
问题 I have a long process and I want to show a user a progress bar where I pass a parameter (percentage) to a Javascript function in my Webform with masterpage. I have this: <script type="text/javascript"> function updateProgress(percentage) { document.getElementById('ProgressBar').style.width = percentage+"%"; } </script> and: <div class="progress progress-striped active progress-success" style="height: 43px"> <div id="ProgressBar" class="progress-bar" role="progressbar" runat="server" aria

Is it possible to use Data Annotations for MVC in an ASP.NET WEBFORM Business Object Class?

前提是你 提交于 2020-01-22 09:45:29
问题 How can I use this convention in an asp.net WEBFORM Business object class? Example In MVC using System.ComponenModel.DataAnnotation; public class Customer { [Required] [StringLength(5,20)] public string FirstName { get; set;} [Required] [StringLength(5,20)] public string LastName { get; set;} } I want to use this data annotation in my asp.net webform businessobject class for client validation and server validation. 回答1: Unfortunately WebForms doesn't have native support of Data Annotations

Hide an ASP.NET Menu Item

只愿长相守 提交于 2020-01-21 06:37:10
问题 I have an ASP.NET webforms application with a Menu control. How does one hide a particular menu item via code? I've seen a few articles pointing out how to do it with ASP.Net membership/roles-based security, but this particular use case has nothing to do with that. I simply need a way to programmatically remove a menu item from code. Any help would be appreciated. 回答1: It would be more straight forward to use myMenu.Items.RemoveAt(0); This will remove the first menuitem myMenu.Items[0]

how to generate code for download a music (mp3) in asp.net c#?

ⅰ亾dé卋堺 提交于 2020-01-17 18:07:32
问题 I have a asp.net webform application (music website). I want to have a download button. So when users clicked on that. selected music start to download with browser.How can I do that? here is the code that I tried: string id_new; id_new = Session["selectedmusicID"].ToString(); DataTable dt2 = new DataTable(); dt2 = blm.selectMusic("sel_music", Convert.ToInt32(id_new)); string test = dt2.Rows[0][9].ToString(); string test2 = test.Substring(9); Context.Response.Clear(); Context.Response.Buffer

how to generate code for download a music (mp3) in asp.net c#?

﹥>﹥吖頭↗ 提交于 2020-01-17 18:07:09
问题 I have a asp.net webform application (music website). I want to have a download button. So when users clicked on that. selected music start to download with browser.How can I do that? here is the code that I tried: string id_new; id_new = Session["selectedmusicID"].ToString(); DataTable dt2 = new DataTable(); dt2 = blm.selectMusic("sel_music", Convert.ToInt32(id_new)); string test = dt2.Rows[0][9].ToString(); string test2 = test.Substring(9); Context.Response.Clear(); Context.Response.Buffer

Application Cache and Slow Process

柔情痞子 提交于 2020-01-17 14:14:49
问题 I want to create an application wide feed on my ASP.net 3.5 web site using the application cache. The data that I am using to populate the cache is slow to obtain, maybe up to 10 seconds (from a remote server's data feed). My question/confusion is, what is the best way to structure the cache management. private const string CacheKey = "MyCachedString"; private static string lockString = ""; public string GetCachedString() { string data = (string)Cache[CacheKey]; string newData = ""; if (data

Why does ddl 'onchange' event not appear in intellisense?

寵の児 提交于 2020-01-17 05:30:07
问题 I was working out a problem with a ddl trying to get a message box to popup when the item changed. You can read about that here >>> How to Popup Alert() from asp:DropDownList OnSelectedIndexChanged? The working answer shows me to use the onchange event but then I'm working in VS2010 this event does not appear in the intellisense dropdown. However if I type it in anyway it works fine. 回答1: For this, you need to understand how the thing works....when you change the value of a input element,

asp menu not working after partial postback

自闭症网瘾萝莉.ら 提交于 2020-01-16 09:02:13
问题 I have a asp:menu that stops functioning after I perform a search on my page. The search uses a update panel and is triggered by a submit button. Once the results are displayed on the page the menu hover effects stop working. It will no longer expand down on mouseover. The clickable links still work. The menu is in the site's master page and is outside the update panel of the search control. Thank you for any help! This is the menu <asp:Menu ID="Menu5" runat="server"

ASP.NET RangeValidator Behaving Strangely

妖精的绣舞 提交于 2020-01-16 06:28:06
问题 It's type attribute is set to string and it's min value = 0 and the max value = 100. I want to insure that the data entered won't exceed the column length defined in the database. Now when I test it, it always display the error message even if I entered one letter or two! 回答1: You should use a RegularExpressionValidator for this. RangeValidators aren't for string lengths. Set the ValidationExpression to something like .? , or you can narrow it to something like \S? or \w? or something if you