Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Wednesday, March 28, 2012

link usage by ajax framework

HI, I am new using ajax... so..I created a small project with a few controls inside a page.I was doing well every think fine.So I started a web test project to see the impact of using ajax inside my page (link usage)...and what I see was a use of a "library" off size 250Kb ...Is this correct I doing something wrong ?

The controls that I was testing was part off the toolkit

Hi,

According to my understanding, you noticed a .js file with size of 250 KB was downloaded.

This is the correct behavior. Actually, AJAX is implemented with javascript, which will be responsible for sending request asynchronously, update contents on the web form. And there are also a lot auxiliary methods and objects.

So, it's normal to see this.

Just pay attention to changing the debug mode to false in web.config before you are going to deploy your application.


I would like to know if this .js will be downloaded at each post in the page? For navigation between different pages that use Ajax technology .js will be downloaded several times? What I expected is that .js was to be downloaded only once. But my tests don't show this! Am I correct? Or I am loosing something Thank you Very Much

You need to set debug to false in web.config.

List Search extender - activation on first load

Hi all,

I've encountered a probem with using the List Search Extender. These controls work fine during general use throughout my project (when the dropdown is selected by either clicking or tabbing on to the control).

However, on several pages I am seeking to set the focus to a dropdownlist which has an associated ListsearchExtender during the initial loading of the page. If I attempt to do this using simply:

Dropdown1.Focus()
or
 
ScriptManger.GetCurrent(Me.Page).SetFocus(Dropdown1)
 
.. I encounter a problem - the dropdown is focussed successfully but the listsearchextender is not activated - the user must click off the dropdown then re-select it.
 
I did find the following code useful:
 
 
function pageLoad() { var extender = $find('<%=lseCust.ClientID%>'); if (extender) { extender._handleFocus(); } }
 .. which I successfully activated the listsearch on page load. However, this also activates it across all postbacks, which is not appropriate.
 
Ideally, I would like to be able to "force" the listsearch to activate in all instances when the control is subject to focus, so I tried the following:
 
 
<script type="text/javascript">function ActivateListSearch() { var extender = $find('<%=Dropdown1.ClientID%>'); if (extender) { extender._handleFocus(); } } </script>Page_Load(ByVal sender as object,ByVal e as System.EventArgs)Handles Me.Load
 Dropdown1.Attributes.Add("onfocus","ActivateCustListSearch()")End Sub
 
.. but this doesn't activate the list search during the first page load (no error is encountered), although the listsearch is operational when the user clicks or tabs onto the dropdown.
 
Has anyone else encountered this issue or found a workaround for it? 
 

Hi,

I think you can use the second parameter of pageLoad method to determine if it's a partialPostback.

For instance:

function pageLoad(sender, args) {
if(args.get_isPartialLoad ()) return;
var extender = $find('<%=lseCust.ClientID%>');

if (extender)
{
extender._handleFocus();
}
}


Saturday, March 24, 2012

Load a javascript file in an updatepanel

Ipresent the context to you. I have a project principal compound of anupdatepanel. When I click on a button, I filled my updatepanel with a"templatd control". This one appears well. This control haves embeddes resources (images + Javascript file). My problem is that my control charges only the images and not my Javascript file. When I use this control in a simple page, it works correctly. I think that it is impossible to charge a fileJavascript in a updatepanel. What do you think about it? Thank you inadvance for your answers.

Damien

Damien,

Personally what I would do as UpdatePanel makes a server request to do your processing in the postback server side, easier and cleaner, you already in the server, then why not. Putting javascript with the UpdatePanel, why? the UpdatePanel is to go to the server without the user to see the request, then just use that!

Makes sense?

Wednesday, March 21, 2012

Loading UserControls in Tabs

Hello folks,

In my project I am using the AjaxToolKit to display Tabs on my page which is inherieted from a master page Script manager and UpdatePanel is on master page. The aspx page has TabContainer:

<ajaxToolkit:TabContainerID="tcMain"runat="server"OnClientActiveTabChanged="ActiveTabChanged"OnActiveTabChanged="ActiveTabChangedServer">

Also on the aspx page I have this to wireup the client side Tab change event:

<scripttype="text/javascript"language="javascript">
function ActiveTabChanged(sender, e) {
__doPostBack('<%= tcMain.ClientID %>', sender.get_activeTab().get_headerText());
}
</script>

On the code behind of the aspx page I have a method that does the work when the active Tab is changed:

protectedvoid ActiveTabChangedServer(object sender,EventArgs e){
// Do something
}

My Tab container has two tabs each of which loads a User control. What I am noticing is that whenever I switch tabs the previously loaded control has to load again, a postback is occuring. The Tab Panel in the container has ViewState enabled.

Should I have to load the UserConrol again when I switch to a different Tab?

Is there a more efficient way of doing this?

Should I unload the UserControl for better performance and making page lighter when switching tabs? Is this the correct way of doing things?

Appreciate your help.

You could put the tab panel inside of an updatepanel.
You could also set up an handler to check each time the tab is changed and load the last control from viewstate (I like to set up a property that saves any control that I load dynamically into viewstate so I can always refer to it when I need it)...


Take the update panel out of the masterpage and put on the page with the tab container.

Update panels are not intended for masterpages.

Hope this helps

DK


Hi,

You have to load the UserControl again. This is a FAQ about dynamic control in asp.net. Please refer to the following explanation.

1. Why do I have to recreate dynamic controls every time? /Why dynamic controls are disappeared on PostBack?

Whenever a request comes, a new instance of the page that isbeing requested is created to serve the request even it's a PostBack. Allcontrols on the page are reinitialized, and there state can be restored fromthe ViewState in a later phase.
The dynamic controls have to be recreated again and added tothe control hierarchy. Otherwise, they won't exist in the page.
Please be careful with when to create dynamic controls. Inorder to keep their state, they have to be created before the LoadViewStatephase. Page_Init as well as Page_Load methods are options available.
For more information about this topic, please refer to thisarticle:
Creating Dynamic Data Entry User Interfaces[http://msdn2.microsoft.com/en-us/library/aa479330.aspx ]

Hope this helps.