postback

ASP.NET DropDownList OnSelectedIndexChanged event not fired

旧城冷巷雨未停 提交于 2019-12-10 13:23:04
问题 I'm trying to use some AJAX and ASP.Net together to enable me to run functions without having to refresh the whole page but i've stumbled across a problem in doing this Here's my code <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddl1" runat="server" OnSelectedIndexChanged="update1" /> <asp:TextBox runat="server" ID="txt1" /> </ContentTemplate> </asp:UpdatePanel> And here's

Retrieving postback from Dynamically created controls in MVC without using FormCollection

≯℡__Kan透↙ 提交于 2019-12-10 12:17:55
问题 I'm passing a List to an MVC view and generating checkboxes for each object in the list (The checkboxes are named t.Name). I'd like to be able to tell which checkboxes were checked once the form is posted. However, I'd like to avoid using the FormCollection object. Is there any way to do this? 回答1: Set the name of your checkboxes to something like "MyObject[" + index + "].Checked", and for each checkbox also put a hidden input field named something like "MyObject[" + index + "].Name" with the

ASP.Net RadioButton loses ViewState

回眸只為那壹抹淺笑 提交于 2019-12-10 12:15:23
问题 I'm having trouble with a simple radio set of two radio buttons (I don't want to use a RadioButtonList [RBL] because RBL doesn't allow child controls, and in my case, if you select one option, I want to enable a textbox next to the button; yes you could hack this with jQuery to move the textbox, but that's dirty!). I would check one, submit the form (either explicitly or through AutoPostBack), and the CheckedChanged event would never fire. When the page was reloaded, both buttons would be

Recaptcha in Updatepanel disappears during PostBack

北战南征 提交于 2019-12-10 12:15:02
问题 I am using Google ReCaptcha V2 and it is inside an updatepanel. IF validation failed ReCaptcha disappears on postback. I read similar topics but I have not yet found an answer that solves my problem. Please help! My ASPX code : <%@ Register Assembly="GoogleReCaptcha" Namespace="GoogleReCaptcha" TagPrefix="cc1" %> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <form id="formRegister" runat="server"> <asp:ScriptManager ID="ScriptManagerRegister"

How do I chain my own JavaScript into the client side without losing PostBack functionality

混江龙づ霸主 提交于 2019-12-10 11:57:06
问题 So I was reading these Asp.Net interview questions at Scott Hanselman's blog and I came across this question. Can anyone shed some light of what he's talking about. 回答1: <asp:LinkButton ID="lbEdit" CssClass="button" OnClientClick="javascript:alert('do something')" onclick="OnEdit" runat="server">Edit</asp:LinkButton> The OnClientClick attribute means you can add some javascript without losing PostBack functionality would be my answer in the interview. 回答2: Explain how PostBacks work Postbacks

Which one is better? Ajax post or page post[Controller httppost] when only one form is there in a page?

混江龙づ霸主 提交于 2019-12-10 11:18:36
问题 I have a page called Bookprogram which contains 6 input controls namely, txtName, txtEmail, txtPhone, selectcat[dropdown for categories], txtDate, txtMessage. Now when am done with all the validations for the above control, I want to store the data in db. I know how to perform both in ajax as well as complete page posting. If it's in ajax, after validations, I would just call $.ajax and post the data as a string and fetch it in controller as below: [HttpPost] public JsonResult BookProgram

.net calendar - making the whole cell perform postback (clickable)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:02:35
问题 I've got a .net calendar up and running and bringing information from a database. By default the day number has a post back action applied to it. What I'm trying to do is have that action apply to the whole cell so the user doesn't need to click on just the text link. I'm the dayRenderer action i have the following line to try and replicate the action but the second argument I'm not sure how to set it. It appears to give it an id e.g. 3315 but I'm not sure how to get the required id manually

disabled dropdownlist does not keep selected value on postback

情到浓时终转凉″ 提交于 2019-12-10 09:56:11
问题 I'm getting a weird behavior with a dropdownlist when I trigger a postback. If the dropdownlist is enabled, the selected value remains the same after a postback. However, if the dropdownlist is disabled (via a javascript when user ticks a checkbox), then the selected value is reset to the first item in the list. How come ? 回答1: you need to look up the value manually (probably store it in another field or so), and then set it yourself in the code behind. This is because if a control is

ASP.NET private member field loses value on postback

醉酒当歌 提交于 2019-12-10 03:02:51
问题 Consider the following code: public partial class TeacherControlPanel : System.Web.UI.Page { protected string username = string.Empty; protected void Page_Load(object sender, EventArgs e) { username = (string)Request.QueryString["username"]; Ice_Web_Portal.BO.Teacher teacher = Ice_Web_Portal.BO.Teacher.GetTeacherByUsername(username); if (teacher != null) { labUsername.Text = username; labName.Text = teacher.TeacherName; labTeacherCode.Text = teacher.TeacherCode; Dept dept = teacher.Department

Do something javascript before asp.net anypostback

試著忘記壹切 提交于 2019-12-09 05:19:56
问题 I wanna do something in javascript before page goes for post back. How to run a javascript function before any asp.net postback? $('form').submit(function () { alert('hello'); }); It doesn't work... :( 回答1: I find the way, in the asp.net forums and it was a some code in codebehind. Just add this to your Page_Load event handler, changing the javaScript string to what you want to happen. string scriptKey = "OnSubmitScript"; string javaScript = "alert('RegisterOnSubmitStatement fired');"; this