VS 2008 OnKeyPress Not Called + JS?
Oct 22, 2010
Code:
<asp:TextBox ID="TextBox1" runat="server" onKeyPress='return maxLength(this,"30");'></asp:TextBox>
Code:
function maxLength(field,maxChars)
{
alert('onKeyPress');
if(field.value.length >= maxChars) {
event.returnValue=false;
alert("more than " +maxChars + " chars");
return false;
}
}
When I Press any Character , maxLength function is not called,WHy SO?
View 5 Replies
Similar Messages:
Jul 16, 2010
I have a form with a default button set.So when i press enter,form is submitted regardless of the focus. My requirement is when focus is inside fileupload control and enter is pressed,instead of submitting the form show browse dialog. So I created a panel and attached a onKeyPress event to this panel
fileUploadDocument.Attributes.Add("onkeyPress", "return ByPassEnter(event);");
<asp:Panel ID="fileUploadDocument" runat="server">
<div>
<uc2:FileUploadControl ID="ucdocxUploadControl" runat="server" ErrorMessageNoFileSelected="select a file for upload."
ValidationGroup="BrandLogoFileUpload" />
</div>
</asp:Panel>
function ByPassEnter(e) {
var evt = (e) ? e : window.event;
var key = (evt.keyCode) ? evt.keyCode : evt.which;
if (key == 13) {
document.getElementById('<%=ucdocxUploadControl.BaseFileUploadControl.ClientID %>').click();
CancelDefault(evt);
}
}
function CancelDefault(e) {
e.cancel = true;
if (e.preventDefault) {
e.preventDefault();
}
e.returnValue = false;
}
When i press enter on fileupload control, browse dialog shows up and when i choose a file or hit cancel on browse dialog,postback happens. e.returnValue = false should prevent the postback but even then postback happens. However if i change onkeypress to onkeydown,everything works and postback doesnot happen.
View 1 Replies
Apr 1, 2010
I found this code to handle textbox key press event, but when I tried it in my program, it says
Public Sub txt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtWeightLoss_Disk3.KeyPress
View 3 Replies
May 6, 2010
I'm using an asp textbox and a search button. In Safari if I click the search button i get redirected to the search results page using javascript window.location.href. But strangely the same javascript will not redirect to the page if I press return in the textbox. Using the alert function I can see that window.location.href has the the correct url and the location bar at the top changes from the search page(default.aspx) to the search results url however when I click OK to the alert box the url at the top reverts back to the default.aspx page. It works on ie7/8/firefox/chrome but not safari. Here is my javascript,cs and aspx code:
function submitSearchOnEnter(e) {
var CodeForEnter = 13;
var codeEnteredByUser;
[code]...
View 3 Replies
Dec 17, 2010
I would like to know whether it is possbile to have a script that allow user to focus one from textbox to another textbox by onkeypress event.
View 4 Replies
Feb 18, 2011
I have a .aspx page that can be called from two other pages in the same project. There is a "Back" button on that page. When the user clicks on the back button, how do I know to which page (called from page 1 or page 2) I should go back?
View 8 Replies
Feb 16, 2010
If VS 2008 and VWD 2008 are both installed on the same machine, will they both use the same Projects folder to keep my projects in?If so, can I open the projects and run them interchangeably with VS2008 and VWD 2008? This is the folder that is located at " User>Documents>Visual Studio 2008>Projects
View 1 Replies
Sep 10, 2010
How can I tell from within an ASP.NET HttpHandler if it is executing because of a call to Server.Execute("myHandler.ashx")or because of the user linking directly to myHandler.ashx? (Besides using a querystring parameter).
View 2 Replies
Mar 22, 2011
i read that whenenver you call an instance of the your site the session_start is called. I am using the following code to create a visitor counter
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application.Add("Myvariable", 0);
}
[Code]....
Hence when I run the program the output is "User No:1"
and i copy the url to another firefox tab and paste it there the output is still the same. Isnt it suppose to increment. My session _start is not being called why ?? I was reading a tutorial in which it is being incremented.
View 2 Replies
Oct 31, 2010
The following code is executed when my app starts
ModelBinders.Binders.Add(typeof(StringValidator), new StringValidatorBinder());
StringValidatorBinder implements IModelBinder and simply throws an exception on BindModel, and I have a break line on there too. So, why does the following post method set "validation" to null and not call my model binder?[HttpPost]public ActionResult Create(string code, string description, StringValidator validation) {......}
View 5 Replies
Apr 1, 2010
found many pages of my maintence website inherits a base page which overrides InitializeCulture to customize some globalization settings. Is this method called everytime for any incoming request
View 1 Replies
Jun 9, 2010
I have an application made on asp.net mvc 2 and it is on IIS 7.5 on my pc I tried profiling it and I noticed that Application_Start gets called more than once, anybody knows why is this happening ?
View 1 Replies
Sep 2, 2010
I have two versions of a website. One runs on IIS server on a local PC, the other runs on the ASP.NET development environment included on Visual Studio (localhost). Apart from that, the file stucture of both is the same, although only the one running on IIS works properly, and this seems to be related to the fact that the IIS version calls Application_BeginRequest() where the other doesn't.
I've looked at the differences between IIS server and the ASP development environment in: [URL], and it says that IIS and the ASP development server deal with static content in that for IIS in that on IIS static content does not go through the ASP.NET runtime like it does on the dev environment (but I'm not sure exactly what this means).
I've done a number of tests involving images, etc, and have noticed that when the image is of the form:
<img src="Image/MyImage.jpg...>
the IIS server version calls Application_BeginRequest(), but the visual studio development environment version doesn't.
However, if I change the above code to use:
<img src="<%=ResolveUrl("~/Image/MyImage.jpg")%>" ...>
it will call Application_BeginRequest().
In my case, it is necessary to call Application_BeginRequest because this creates a new path and calls
RewritePath().
The problem occurs when using links such as <a href="..." ...>, because if I use static content it won't call Application_BeginRequest() and the path won't be re-written. But If I change it to href=" %=ResolveUrl("~/...")%>" (for some reason, it will only call BeginRequest() if the path begins with a tilde ~), the path is re-written incorrectly.
I'm not really sure how to find out why the IIS version is calling Application_BeginRequest() from all the time (the callstack just says "external code"), or why it is calling it whereas the local dev server version isn't.
If anybody can explain this, or knows of any sites that go into this so I can master the basics, I'd be very grateful.
View 6 Replies
Aug 11, 2010
In my office I am the only Web Developer. There are no other Web Developer.
I was confused by my co-worker programmers regarding the meaning of Code Behind. They told me there is no such Code Behind.
highlight which is CodeBehind from these 2 sets of sample coding:
these are from HTML
[code]....
Of the 2 sets of sample cpding which one is called CodeBehind ?
View 2 Replies
Aug 27, 2010
The page I'm editing had three tabs, each tab contains a diffrent grid view which is populated by a search box with in the tab. Each row in the grid view has a check box. When a print button is pressed all records with a tick in the check box should be printed off. Then page then reloads but some of the content is missing due to the way the page has been coded. This is becuase some of the code is only called when the tab is clicked not on postback. Is there anyway that I change the following code so that it's called after postback? These are the functions that are causing the most problem.. I need them to be loaded for the correct tab on postback.. I can't do it for all three as the code takes forever to run in that case.
AddActionsToGridView(gvGlobal);
AddCheckboxesToGridView(gvGlobal);
{
if (tabconConsignments.ActiveTabIndex == 0)
{
dtGlobalIDConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "GlobalID", "", "");
//Global ID Tab
gvGlobal.DataSource = dtGlobalIDConsignments;
gvGlobal.DataBind();
//Actions
AddActionsToGridView(gvGlobal);
AddCheckboxesToGridView(gvGlobal);
}
else if (tabconConsignments.ActiveTabIndex == 1)
{
dtCreatedDateConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "CreatedDate", "", "");
//Created Date Tab
gvCreationDate.DataSource = dtCreatedDateConsignments;
gvCreationDate.DataBind();
tbCreationDateSearch.Text = "";
//Actions
AddActionsToGridView(gvCreationDate);
AddCheckboxesToGridView(gvCreationDate);
}
else if (tabconConsignments.ActiveTabIndex == 2)
{
dtAccountsConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "Account", "", "");
//Account Tab
gvAccount.DataSource = dtAccountsConsignments;
gvAccount.DataBind();
AddActionsToGridView(gvAccount);
AddCheckboxesToGridView(gvAccount);
}
if you want me to post any more code or any more info it's been a hard one for me to get my head around so I might of missed something out.
View 2 Replies
Apr 13, 2010
I made a custom handler that derives from MvcHandler. I have my routes using a custom RouteHandler that returns my new handler for GetHttpHandler(), and I override ProcessRequest() in my custom handler. The call to GetHttpHandler is triggering a breakpoint and my handler's constructor is definitely being called, but BeginProcessRequest() is being called on the base MvcHandler instead of ProcessRequest().
Why are the async methods being called when I haven't done anything to call them? I don't want asynchronous handling, and I certainly didn't do anything explicit to get it. My controllers all derive from Controller, not AsyncController.
I don't have the source code with me right now, but I can add it later if needed. I was hoping someone might know some of the reasons why BeginProcessRequest might be called when it's not wanted.
View 1 Replies
Jul 23, 2010
I've seen a few posts about Application_BeginRequest, but non seems to have my problem.
My Application_BeginRequest is being called for every image in my website.
The StaticFile Handler is enabled with * as the Path, but it's at the end of the list.
Is this the normal behaviour? Or should I add .gif, .jpg and so on on top of the list?
This is on my IIS7.5 Win7 Development Server. Didn't check it on the production server yet.
Update:
Setting runAllManagedModulesForAllRequests=false would help. But then the ASP.NET URL Mapping does not work anymore. I tried disable it just for the image directly, but that had no effect?
<location path="Resources">
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
</modules>
</system.webServer>
<location>
View 1 Replies
Feb 22, 2010
This is the setup in short. I have a big table. Everytime a cell get focus an asyncron call to the server is done (with PageMethods) and some data is returned and updates a infobox in the page.I have written code that makes it possible to navigate between cells with the arrow keyes.
The problem occurs when I shift focus fast through several cells in order to get to the cell I want. Every get-focus is executed and since the communication with the server takes about half a second it get quite irritating and not very user friendly.Ideally I would like to execute only the last focus event. But how? I cant know which event is the last one, can I?
View 2 Replies
Dec 6, 2010
I have a user control with cascading dropdownlists. When I populate the controls in the Page_Load event, the second dropdownlist has duplicate entries. These controls are inside AJAX UpdatePanels and I need to find out when DataBind is called on the second dropdownlist to see why it is being called twice.
I am using a SqlDataSource with a ControlParameter to populate the second dropdownlist, not doing it through the code behind.
Is there a window in Visual Studio 2008 that will let me see when DataBind is being called?
View 4 Replies
Feb 24, 2011
I am new to ASP.NET (2 months) and my very first assignment is to create a website for a municipality. Purchasing as much reading material as possible, I got started and after some time, I have a decent website (coded in C#) that is ready to be internally tested on the departmental webserver. The Web server is running IIS 7 and the pages were developed with Visual Studio 2010. On the main default page, I wanted to implement a slide show using the AJAXControlToolkit which I installed. I watched the ASP.net tutorial [URL] and literally coded my slide show verbatim. I try to launch my slideshow within my default.aspx page and absolutely nothing happens. The steps that I took are
1. Created a webservice (SlidesService.asmx) which generated a code behind file (SlidesService.cs).
2. I created the web method GetSlides() containing a 22 element array which I place in the code behind file.
3. Implement the ToolkitScriptManager establishing my image control.
4. Defined my Previous, Play and Next buttons.
5. Implemented my SlideShowExtender providing my SlideShowServicePath and SlideShowServiceMethod.
Assumptions: In doing all of the above, I noticed that the SlidesService.asmx file needs no code (as I placed all code within the codebehind file). The SlidesService.cs code behind file should reside in the App_Code folder whereas the the SlidesService.asmx file can remain in the root folder. No Button e.g Button_Click needs to be attached to the code behind source file. If I have conveyed my steps properly, can anyone shed some light on why when clicking the play button, nothing happens? Code is listed below.
[Code]....
SlidesService.asmx - code
<%@ WebService Language="C#" CodeBehind="~/App_Code/SlidesService.cs" Class="SlidesService" %>
View 2 Replies
Mar 9, 2011
Error:An item with the same key has already been added.
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9382923
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +252
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer) +91
System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +228
System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +392
System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +147
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +98
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +2504.................................
View 2 Replies
Aug 24, 2010
I have an application written in c# and I am using the sqlClient to connect to database. I have several methods and I usually open the connection in a try catch block
try{
**open connection**
//Mehod1()
//Method2()
........
}catch(exception){
//Do something
}finally{
**close connection**
}......................
View 3 Replies
Jan 1, 2010
to make sure, that my problem is not made by myself i create a new mvc solution and added following code into Views/Home/Index.aspx:
[Code]....
The corresponding HomeController was added by following Code:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SendMail(string username, string email, string subject, string message)
{
ViewData["Message"] = "Mail was sended....";
return View();
}
The ActionResult was not called - what do i have to do else? What do i forget?
I made a look to the Orange-Template where i found to do it in that way and in that Template it works.
View 13 Replies
Aug 15, 2010
I am trying to implement a custom HTTPModule for ASP.NET. I have a very simple html page with an image in it and an HTTPModule that hooks into the BeginRequest event. When I debug with Visual Studio's dev web server, my module is called twice: one for the initial page request, then once for the image request. This is what I expected. However, when I deploy my application to IIS, the module is only being called once for the page request.
View 2 Replies
Mar 8, 2011
Error:An item with the same key has already been added.
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9382923
[code]...
View 7 Replies