Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Wednesday, March 28, 2012

postback problem

i have asp.net web page,on page load i create a simple html table with fixed no of rows and no of columns and their names are determined dynamically.now i have few javascipt functions for adding a row to table,for adding another column to table and for removinga row from table.

also i have a asp:button on click of which a xml file is generated from the data filled in by user in the table.but as soon as i hit the asp button to generate xml all newley added rows and columns are deleated.Is it possible to call a server side function without posting the page back.

Yes, it is

take a look at this article about client scripts callbacks:

http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/

Cheers,

Yani


hey went throught the article actually i mean new to all this so didnt get it completely some code help from ur side will be appriciated

actually i have a method on server side that accepts the html table parses it and writes the data of html table in a xml file.

and i want to call this method on click of a button and without postback.

thanx in advance

sandeep


Sorry man,

I haven't put the client scripts callbacks into practice yet too.

I was going to use them to create a dynamic progress bar, but then i've decided to use the ajax update panel.

It was much faster and cheaper.

Cheers,

Yani

Postback with MasterPage

hi all

i want to load other page with masterpage without postback

any one cane help me?

AOJ

Hi,

In my opinion, there is not elegant way to achieve this.

First of all, please note that MasterPage is quite different from a container (e.g.: frameset/iframe) in the client side's point of view. The client isn't aware of the existance of masterPage at all. Every actions fired by controls in the masterPage is the same as the one fired by control in a normal page.

So, if you'd like to implement this, what you need to do is to place a UpdatePanel on the masterPage, and load different controls into it programmatically. Then update the UpdatePanel.

Pre load

Hi,

I would like make a pre load during load my page.

How calculate the time of load ?

Hi Michel,

Can you please give some more details on what exactly you're trying to do?

Thanks,

Eilon


It's ok, I found it.

<atlas:UpdateProgressrunat="server"ID="UpdateProgress1"><ProgressTemplate><br/><br/><br/><imgsrc="Images/indicator.gif"alt=""/><br/>Loading...</ProgressTemplate></atlas:UpdateProgress>

Pre selected item in a cascading dropdownlist

I have a set of 3 dropdowns that im using the cascading dropdownlist ajax with. They all load corectly with the webservice and work great, but the form is an inventory entry screen and I need to update an existing inventory sometimes. So is there a way to pre-select all 3 dropdown list boxes? I tried "CascadingDropDown1.SelectedValue = "MACK";" but it gets erased when the webservise returns the data.


Maybe you got it solve by the date, but i figure out a way to lead with cascadingDropdownlist and preselection.
In my case I have 3 dropdownlist (ddl) inside a formview and depending is a session variable is already filled the value for the first DDL (parent) is changed.

In the following code, FvwPostOff is a formview which contents my DDL and CascadingDropDown (CddBuilding) extenders. The thing is to set the value by the CascadingDropdown extender instead of the DDL direclty:

ElseIf (Session("BUILD_NB") IsNotNothing)Then Try Dim CddBuildingAs CascadingDropDown = FvwPostOff.FindControl("CddBuilding") CddBuilding.SelectedValue = Session("BUILD_NB")Catch exAs IndexOutOfRangeException' nothingEnd Try End If
Hope this help

Monday, March 26, 2012

Proble with Accordion Control and user control

There is one problem with Accordion Conrol

I place use control in ContentTemplate of Accordion Control.

Now problem is that when Accordion Control load first HeaderTemplate Load then page load event of User control which i placed in ContentTemplate fire.

So this is problem.

Please help me.

Thanks in advance.

Not sure at what your trying to get at here, but see if this page helps.

http://asp.net/ajax/control-toolkit/live/Accordion/Accordion.aspx


Hi Piyushp,

piyushp:

Now problem is that when Accordion Control load first HeaderTemplate Load then page load event of User control which i placed in ContentTemplate fire.

It is normal to say so. Based on the order of execution, the inner contronl's pageLoad event will be occurred before the outer control(or container)'s.

Best regards,

Jonathan.

Wednesday, March 21, 2012

Problem in Speeding Up First Load of this page...

Improving Response Loading

Hi,

Is there a guide in improving loading performance when using atlsa controls liek update panel, tabcontainer and tabpanels, multiview and view, Gridview, composite controls, web user controls, updateprogress and other asp.net web controls together in a web user control. I have this user control that contains 2 tabcontainers, first, has 3 tabpanels, second,
is contain as child tabpanel of one of outer tabpanels, has 6 tab panels, currently 3 of these tab panels has usercontrols, 2 outer tabpanels has gridview in them.

Is there a way to speed up loading for first time? Any ideas, I time first load of this page, it time between 4 to 6 seconds, sometimes even 9 seconds.

Basically AddButtonAttribute(), GetPostBackAugument(), GetGlobalParameter(), PopulateFilterDropDown(), PopulateFilterDropDown(), and RestrictTabs() and base.OnLoad(e) are executed when this page is loaded for first time.

protected override void OnLoad(EventArgs e) { AddButtonAttribute();//Add Attribute javascript functionstring args = GetPostBackArgument();//Get _PostBack(control, argument)string tabPage = GetGlobalParameter();//Get a global hidden field valueif (!Page.IsPostback) {if (tabPage !=string.Empty && args !="Redirect") RedirectTabPage(viewPage);//Where a TabPanel speciifc function is handled including loading usercontrol to this usercontrol }else {if (tabPage !=string.Empty && args !="Redirect") RedirectTabPage(tabPage);//Where a TabPanel speciifc function is handled including loading usercontrol to this usercontrolelse if (args =="ContentRedirect") PopulateFilterDropDown();//Populate 3 Dropdownlist controls } RestrictTabs();//Restrict Tabpanelsbase.OnLoad(e); }

Structure like this xml:

4 usercontrols

<hiddenfields = 14>
<UpdatePanel>
<TabContainer>
<TabPanel>
<MultiView>
<View>
<UpdateProgress></UpdateProgress>
<control></control>
<GridView></GridView>
<control></control>
</View>
<View>
<Table>
<control>
</control>
<control>
</control>
</Table>
</View>
</MultiView>
</TabPanel>
<TabPanel>
<MultiView>
<View>
<UpdateProgress></UpdateProgress>
<control></control>
<GridView></GridView>
<control></control>
</View>
<View>
<Table>
<control>
</control>
<control>
</control>
</Table>
</View>
</MultiView>
</TabPanel>
<TabPanel>
<TabContainer>
<TabPanel>
<Table>
<control>
</control>
<control>
</control>
</Table>
</TabPanel>
<TabPanel>
<Table>
<control>
</control>
<control>
</control>
</Table>
</TabPanel>
<TabPanel>
<Table>
<control>
</control>
<control>
</control>
</Table>
</TabPanel>
<TabPanel>
<UserControl></UserControl>
</TabPanel>
<TabPanel>
<UserControl></UserControl>
</TabPanel>
<TabPanel>
<UserControl></UserControl>
</TabPanel>
</TabContainer>
</TabPanel>

</TabContainer>
</UpdatePanel>

Thabks in advanced.

I was wondering using Session to replace HiddenFields to speed up loading, and put controls found inside tab into a user control and loading them when it is needed, will this speed up loading process a lot?

Try this set

<% @.Page Trace="True" %>The trace information will show you exactly how large your ViewState is for that page.

try to figure out which controls you can disable the ViewState for (EnableViewState="False") or what might be causing your ViewState bloat.

Check debug="false" is et or not in web.config, it will improve some performance

Problem Loading URL into Div

On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for quite a bit and found similar problems, but no set solutions.

Here is the JavaScript I have to load a URL into a Div:
function setResponseHtml(pUrl, pDiv) {
var lHttp = getHTTPObjectHtml();
var lUrl = pUrl;
lUrl = lUrl.replace("+","%2b");
if (isBusy) {
lHttp.onreadystatechange = function () {}
lHttp.abort();
}

lHttp.open("GET", lUrl , true);
lHttp.onreadystatechange = function() { getHttpResponseText(pDiv, lHttp); };

if (window.XMLHttpRequest) { // Mozilla check
if (!isBusy) {
isBusy = true;
lHttp.send(null);
}
} else { // IE Check
isBusy = true;
lHttp.send(null);
}
}

function getHTTPObjectHtml() {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
return http_request;
}

function getHttpResponseText(pDiv, pHttp) {
var lHttp = pHttp;

if (lHttp == null) // just in case!
lHttp = gHttp;

if (lHttp.readyState == 4) {
isBusy = false;

var status = "";
try {
status = lHttp.statusText;
if (lHttp.status == 200) {
var htmlDocument = lHttp.responseText;
document.getElementById(pDiv).innerHTML = htmlDocument;
}
} catch(e) {
status = "Trouble accessing it";
document.getElementById(pDiv).innerHTML = e.message;
}
} else {
if (getAjaxLoadingMessage() != '' && getAjaxLoadingMessage() != null) {
// only display a loading message if it is defined
setVisible(pDiv, true);
document.getElementById(pDiv).innerHTML = getAjaxLoadingMessage();
}
return;
}
}

var gAjaxLoadingMessage = '<b>Loading...</b>';

function setAjaxLoadingMessage(pMessage) {
gAjaxLoadingMessage = pMessage;
}

function getAjaxLoadingMessage() {
return(gAjaxLoadingMessage);
}

This is called from the HTML via: setResponseHtml(urlString, divString);
urlString is a string containing the URL that I wish to load in the div, and divString a string containing the id of the div I wish to load the URL into.

I've tested my code on IE before and it worked properly with a very small file with nothing in except for a couple words. I think the problem may go back to these pages, both the one the users calls the function from and the page to be loaded, contain SharePoint Web Parts. That is the only difference I can think of between the original pages I used to test the code and the pages I am working with now.

An error occurs in IE when trying to load the Div, the error being "[object Error]" and the error message being "Unknown runtime error" if I print e and e.message respectively from the getHttpResponseText function.

This is the section of code where the error occurs:
try {
status = lHttp.statusText;
if (lHttp.status == 200) {
var htmlDocument = lHttp.responseText;
if (gAjaxForeground) {
setVisible(pDiv, true);
}
document.getElementById(pDiv).innerHTML = htmlDocument;
}
} catch(e) {
status = "Trouble accessing it";
document.getElementById(pDiv).innerHTML = e.message;
}

I can't figure out exactly why the error is happening, nor how to correct it. If I change the line "document.getElementById(pDiv).innerHTML = htmlDocument;" to "document.getElementById(pDiv).innerHTML = 'Any text here';" I recieve no errors, so apparently IE doesn't like setting the innerHTML of the page to be loaded to the statusText. Why that is and how to fix it is what I'm hoping to find out.

Just a quick question... why aren't you using IFRAME (or whatnot) for something like this. If you're loading an entire page, you're going to have issues like duplicate HTML and BODY tags.

-Damien


The main reason behind using a DIV is because the content from the page being loaded into the div is dynamic content, and the DIV will resize automatically if needed. One other thing to note is that this DIV tag isn't always visible on the page. When the user mouses over an item on the page a pop-up comes up displaying additional information about the object, as well as allowing the user to edit such information, which is where the AJAX comes in - allowing the user to edit the information without straying away from this page, and the page being loaded into the pop-up is the page that has done the update and is displaying the results. I haven't worked with IFRAMEs that much, but from my understanding all of this is not that possible with them - correct me if I'm wrong. I have thought about about duplicated tags, but in the past and during my testing I've never experienced any problems by having such.


Well, you can't push an HTML string into an IFRAME, but you can load a URL. Think of an IFRAME like your DIV; it's a container. You can perform client-side logic with it (e.g. show/hide) and it's the way to host another page inside a page (like you are doing).

Seehttp://en.wikipedia.org/wiki/IFrame andhttp://msdn2.microsoft.com/en-us/library/ms537627.aspx.

Using the DIV and having duplicate HTML and BODY (not to mention HEAD, etc) will cause issues; plus it's not well formed at all.

Hope this helps you.

-Damien


With a bit of help from someone and a bit more searching online I discovered the cause of my problem. Thought I'd post the actual reason for the problem and my resolution here for anyone that might be having similar issues.

The reason for the Runtime Error were Element Prohibitions within the HTML. The DIV that I was trying to insert into was surrounded by FORM tags and the page I was trying to insert into the DIV had FORM tags within it. To put it simply: You cannot have a FORM inside of a FORM.

See this URL for more information: http://www.w3.org/TR/xhtml1/#prohibitions

IE upholds this, where as Firefox doesn't care and just renders it on screen how it thinks the output should look which is why I was having this problem only in IE.

I couldn't remove the FORM tags because the website I am working on is a SharePoint site that uses Web Parts (which are required to have FORM tags around them - if I removed them I got errors that bluntly said FORM tags were needed). So, to overcome this I modified the function getHttpResponseText() (See my first post to view the code). Rather than dump the repsonseText straight into the innerHTML of the DIV tag I used indexOf to find the start and end of the data that I specifically wanted (in my specific case one table on the page) and used a substring to cut that out from the responseText and dump that into the innerHTML of the DIV, thus eliminating the FORM tags.

No iFrames involved and everything works splendid. :p

On a side not, I went to set my thread to 'Resolved' and it was already set at that. I definitely never did that since I didn't have a resolution until today. If code in the forum did that, I would correct it ASAP. If a person did that, I would smack him/her for not reading the thread properly. Suggesting to use an iFrame as an alternative was never a solution. It was just what I said - an alternative where the original problem still remained. The reason for the error, nor a solution to fix it never existed in this thread until the post I am making now.