Controlling the page from reaching the top of the page - asp.net

I have a registration page with many fields and DDl's when i scroll down and select the ddl value then the page going to top of the page and again i have to scroll to the control and have to select the page.How to control the page by stopping at the control even though the value is changed.

Use MaintainScrollPositionOnPostback="true" in Page directive
Something like this
<%# Page MaintainScrollPositionOnPostback="true" %>
to know more about this Go here.
Alternatively you can, put this in Web.config to make this setting global, By this
<?xml version="1.0"?>
<configuration>
<system.web>
<pages maintainScrollPositionOnPostBack="true">
</pages>
</system.web>
<configuration>

Related

Allow < and > to be entered into text fields to submit in asp.net?

For some weird reason when I enter such characters in text fields and press submit button I getting blank page loaded and I don't see any errors appear.
Include requestValidationMode in your web.config file.
<system.web>
...
<httpRuntime requestValidationMode="2.0" />
</system.web>
Also you can set ValidateRequest to false in your page directive.
<%# Page ... ValidateRequest="false" %>

AjaxFileUpload Issue not showing up properly

I've recently started working on a new project and have come across some difficulties using the AjaxControlToolkit (more specifically the AjaxFileUpload control). I've used this toolkit and control on other projects successfully but I'm not sure what's going on in this one. I've referenced the AjaxControlToolkit, put the required lines in my web.config, put the required lines in my aspx pages and set up a script manager and everything seems to be good. The site launches without error and it sort of shows up but it's not working properly. Basically what's showing up is a blacked out box that looks like the "Upload" button, which when clicked allows me to select a file. However none of the other functionality of the control is working. The first two blocks in the image are two seperate FileUploadControls and the 3rd block is an asyncfileupload control....Anyone have any idea what's going on!?!
see image here: http://img571.imageshack.us/img571/3417/screenshot20130223at111.png
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControlToolkit" %> //at top of page
<AjaxControlToolkit:ToolkitScriptManager ID="tsm1" runat="server"></AjaxControlToolkit:ToolkitScriptManager> //on page
<AjaxControlToolkit:AjaxFileUpload ID="ajaxupload1" runat="server" />//on page
<pages>//web.config
<controls>
<add tagPrefix="AjaxControlToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
</pages>
As I've said the project builds and launches fine, no errors, and as you can see in the screenshot it attempts to build the controls but something is off...
It was something in my web.config, not 100% sure what but I was messing around with it and got it working fine. So if anyone else has this issue it's probably something in your web.config :)
I had to add this to my web.config file:
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>

Save position on site after postBack in asp.net 2.0

Is there any easy way to save users position on the site after postback ?
using maintainScrollPositionOnPostBack="true" in my web.config pages section doesnt work.
I mean it does work but only in ie. Is there any way to make it work on firefox and chrome ?
thanks for any suggestions
Koder Gurl had the same type of problem back in 2010. She posted the code that was giving her trouble and from the sounds of it, she had the browser issues you are having.
Try looking at her solution at this page: http://www.kodergurl.com/2010/08/maintain-scroll-position-on-post-back.html
I hope that will help you.
This can be done in different ways as below:
a. Set MaintainScrollPositionOnPostback property to true in Page directive for specific page(s).
<%# Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default"
MaintainScrollPositionOnPostback="true" %>
b. For whole site, add below section to web.config file.
<configuration>
<system.web>
<pages maintainScrollPositionOnPostBack="true" />
</system.web>
</configuration>

Are themes visible at design time?

This is my first experience with themes.
I've created a skin file for a textbox and the defined theme is only visible at runtime.
Is this the way theme works or I am missing something?
You should use StylesheetTheme property that can be set on page level or globally
Page Level
<%# Page Language="C#" StylesheetTheme="MyTheme" %>
Global (web.config)
<system.web>
<pages styleSheetTheme="MyTheme" />
<system.web>

Cannot see new asp.net user controls

I am feeling like an idiot right now, but I cannot for the life of me figure out why I cannot seem to call user controls from within my asp.net webpage. I'm still learning asp.net but I can't find any information from searching on google.
I'm trying to load a specific control on the page when the user presses a linkbutton. So I created an empty user control via the right click menu:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
In other words, I have not touched any part of the created user control. Yet attempting to create this web control and add it to the form seems to not work, as it claims that the WebUserControl class does not exist (I have no other controls in my project):
UserControl blah = new WebUserControls();
produces a "The type or namespace is invalid". Why can none of my asp.net webform pages get the control into scope?
The new control must be added to the site's Web.config file.
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="my"
tagName="WebUserControl"
src="~/WebUserControl.ascx"/>
</controls>
</pages>
</system.web>
</configuration>
Use this to place the new control in an .aspx page.
<my:WebUserControl runat="server" ID="MyWebUserControl" />
In addition to registering them one-by-one in web.config, you can also use a <%# Register %> directive in the source of the markup files that reference the control.
Or, you can move your controls into a DLL and include them all by referencing the assembly from your web.config (takes some extra work, though).

Resources