asp.net-3.5

Stop postback on TextChanged

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 08:54:03
问题 I have a textbox in an aspx page that has a TextChanged event attached to it. I also have a validator attached to the textbox. When the text is changed, the validate triggers but in case there is an error the textchanged event is still called. Do you know if it's possible to stop the postback on textchanged if the validator fires? <asp:TextBox ID="txtQuantity" runat="server" AutoPostBack="true" ontextchanged="txtQuantity_TextChanged"></asp:TextBox> <asp:RequiredFieldValidator ID="reqQuantity"

ASP.net DropDownList with no selected item

◇◆丶佛笑我妖孽 提交于 2019-12-19 05:43:46
问题 I have a ASP DropDownList with items added to it. All what I want is to make the selection after the page loaded empty so there is no a selected item. How can I do that? 回答1: You can add an empty item to the top of your dropdownlist programmatically like this: myDropDown.Items.Insert(0, new ListItem(string.Empty, string.Empty)); myDropDown.SelectedIndex = 0; 回答2: Not sure I understand your question but try this: DropDownList1.ClearSelection() or DropDownList1.SelectedIndex = -1; 回答3: You can

Asp.net checkbox and html data attribute

蓝咒 提交于 2019-12-18 14:13:14
问题 In asp.net, if you use a custom attribute, usually it is rendered as-is. Considering this markup ( note: attributes such as id , name and for were removed in all examples as their generated id/names are verbose): <asp:TextBox runat="server" data-foo="bar" /> Is rendered in asp.net as: <input type="text" data-foo="bar" /> That is, asp.net keeps data-foo untouched. Check box are usually rendered like this: <asp:CheckBox runat="server" Text="Normal" /> Renders as: <input type="checkbox" />

Validation of viewstate MAC failed when on page for 20+ minutes

孤街醉人 提交于 2019-12-18 13:24:28
问题 If you open a web page on one of the websites hosted on our server, leave it for 20 minutes and then submit a form, a Validation of viewstate MAC failed. error occurs. What possible reasons could there be for this? 回答1: There's a few reasons this can happen: Auto-Generated Machine Keys: If your application pools have the default idle timeout of 20 minutes AND you're using auto-generated validation and decryption keys then each time the pool starts it will generate a new set of keys. This

Help with C# HttpWebRequest URI losing its encoding

守給你的承諾、 提交于 2019-12-18 13:15:32
问题 Having a problem with HttpWebRequest decoding my encoded URL. var requestUrl = "https://www.google.com/webmasters/tools/feeds/http%3A%2F%2Fwww%2example%2Ecom%2F/crawlissues/"; var request = (HttpWebRequest)WebRequest.Create(requestUrl); When looking at end request URL is becomes: https://www.google.com/webmasters/tools/feeds/http://www.example.com//crawlissues/ Which of course returns a 400 Bad request. I am guessing it is something todo with the URI class rather than HttpWebRequest. How do I

ASP.Net textbox onblur event

安稳与你 提交于 2019-12-18 12:15:45
问题 I have a textbox, whose values I need to validate (if value of textbox is 50, then display message in lblShowMsg) when the user tabs out of the textbox (onBlur event). I can't seem to get the syntax right. I have this code on my pageload event: protected void Page_Load(object sender, EventArgs e) { txtCategory.Attributes.Add("onblur", "validate()"); } But I can't seem to get the javascript code correct. Any suggestions? 回答1: In the Code behind: (VB.NET) On the page load event txtAccountNumber

How to save video into database using c#?

旧城冷巷雨未停 提交于 2019-12-18 09:51:52
问题 I have scenario where i want to store video into database and show in grid to download from database ,i will upload video by fileupload control and it should be sql server2008 database,which is best way in c# and asp.net? 回答1: There are many link for it. Check out this. http://weblogs.asp.net/hajan/archive/2010/06/21/save-and-display-youtube-video-links-on-asp-net-website.aspx http://forums.asp.net/t/1104451.aspx/1?How+to+retrieve+video+file+from+sql+server+database http://www

How to save video into database using c#?

牧云@^-^@ 提交于 2019-12-18 09:50:05
问题 I have scenario where i want to store video into database and show in grid to download from database ,i will upload video by fileupload control and it should be sql server2008 database,which is best way in c# and asp.net? 回答1: There are many link for it. Check out this. http://weblogs.asp.net/hajan/archive/2010/06/21/save-and-display-youtube-video-links-on-asp-net-website.aspx http://forums.asp.net/t/1104451.aspx/1?How+to+retrieve+video+file+from+sql+server+database http://www

Change Default “Default.aspx” to “Index.aspx” on Visual Studio 2010

本秂侑毒 提交于 2019-12-18 05:21:11
问题 Whenever I create a new Web Form on Visual Studio 2010, the default name is always "Default.aspx". This is a slight pain as I'm having to change it to "Index.aspx" each time. How can I change this so that "Index.aspx" is the default name? Thanks. 回答1: You can by modifying the associated .vstemplate DefaultName element. For example, you might find the webform template you need to modify in a directory similar to the following: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE

Access a control inside a the LayoutTemplate of a ListView

♀尐吖头ヾ 提交于 2019-12-18 04:29:15
问题 How do I access a Control in the LayoutTemplate of a ListView control? I need to get to litControlTitle and set its Text attribute. <asp:ListView ID="lv" runat="server"> <LayoutTemplate> <asp:Literal ID="litControlTitle" runat="server" /> <asp:PlaceHolder ID="itemPlaceHolder" runat="server" /> </LayoutTemplate> <ItemTemplate> </ItemTemplate> </asp:ListView> Any thoughts? Perhaps via the OnLayoutCreated event? 回答1: Try this: ((Literal)lv.FindControl("litControlTitle")).Text = "Your text"; 回答2: