Showing posts with label guys. Show all posts
Showing posts with label guys. Show all posts

Monday, March 26, 2012

Updating ContentPlaceHolder using UpdatePanel(like using frames)

Hi guys,

Is there a way to update the whole Content page without master page refreshing it self? like same effect as using frames or iframes in html.

I tried following, just simply placing script manager and wrapping ContentPlaceHolder with UpdatePanel, which didn't work.

Any suggestions?


<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
<html>
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
<div id="main"
<div id="titleBar">Title</div>

<div id="siteMenu">
<asp:Menu ID="Menu1" runat="server" SkinID="MenuBar" DataSourceID="SiteMapDataSource1" OnMenuItemClick="Menu1_MenuItemClick">
</asp:Menu>
</div>


<div id="content">

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate
<asp:contentplaceholder id="contents" runat="server"></asp:contentplaceholder>


</ContentTemplate>
</asp:UpdatePanel>
</div>


<div id="footer">footer</div
</div
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>



Sorry to say that master pages and AJAX don't work together in that fashion (seehttp://odetocode.com/Blogs/scott/archive/2007/01/03/9682.aspx).

There are lots of ways to refresh the content inside of the page using AJAX, but what you are trying to do requires the browser to load an entirely new page. :/


Thanks Scott.

I won't be wasting any more time trying to figure that one out.

Guess I am back to using good old Iframe.

Cheers

Dosa.

Updating Issue: when Im trying to update from 1.0.60504.0 to 1.0.60731.0

Hi guys,

I'm developing a site (which is still Local and not uploaded yet) that uses Atlas technology.

Everything was good since I just tried to update Atlas Toolkit and Atlas Toolkit Extender to add some extra feature like rating and etc.

I got "Object reference not set to an instance of an object." !

firstly I thought it's because of my settings but I search and found that there is no problem in that matter, when I replaced new ones (Microsoft.AtlasControlExtender.dll, and AtlasControlToolkit.dll) with older ones, the problem resolved.

But I can't use new features on my site!SadConfused

Can anybody help please?!

Just a thought, but have you replaced Microsoft.Web.Atlas.dll as well? (you will need to if you are updating the toolkit)

Well, I did it, but when I saw your message I make it double check and for more accuracy I copy all DLL's related to Atlas from Atlas toolkit's sample website's bin folder, the problem still exisis!

Here is the stack trace for the error it may helps:

[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.AtlasControlExtender.ExtenderControlBase`2.ConnectDataBindingHandlers() +241
Microsoft.AtlasControlExtender.ExtenderControlBase`2.OnInit(EventArgs e) +31
System.Web.UI.Control.InitRecursive(Control namingContainer) +345
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1795


That's helpful - thanks.

You'll get this exception if the extender can't find one of the target controls (e.g. the value in TargetControlID). I've made a code change to help with debugging this, but double-check to make sure that each of those targets is correct.

You can also try handling the OnResolveClientID event that the extender will raise when it can't find a target as well to work around this.


I double-checked those but everything seems to be just fine!

Plus with no change in codes and just with replacing new DLLs with older ones this problem arose!

I'm just confused! I change all references through the refernces page and I think everything must be in its place, but still I stuck!

and the Debugger won't help me anymore! and this stack trace is the only thing I have!

Please Help!


Did you try handling OnResolveClientID?
I wonder if your situation is anything like http://forums.asp.net/thread/1366243.aspx ?

Yes it's the same code - but we're still not sure how folks are getting into that state.


Well, I havre to say "I'm not sure!"

you know, because Atlas is a new technology and I'm new to it too, when I want to add some feature to my site, FIrst I try to check it in a Test project to be sure, but situation is really different now!

because I have lots of Atlas extender's controls on my pages (specially in my Master page) and they are all good until I update DLL's, it's even harder to understand.

and for you last question, Yes I handled that handler but still same Error, I don't know but I think this error would happen even sooner than that you may think in its life time so this handler wont be any help.


Could you (or someone) paste in code that causes this? The fix we have didn't address the problem, so we're not sure what the exact scenario is. If you have the ASPX that causes it, that would be very helpful.

well,

I can't paste codes here (as they are more than 20 ASPX pages)!

but if I could it would not be hepful because we can't find the source of error and Stack trace is no help for ASPX pages I think.

but, let me tell you the scenarion one more time,

I just started to develope an Atlas Based web site but it takes such long time that I can now use July CTP Atlas Toolkit Control too!, but I have been using previous version of toolkit before, and this site contains some features like autoupdate panels, collapsible panels, alwaysvisible controls and all of them works well with previous version of Toolkit but as I got july CTP, and I found Ratings really helpful, I decided to use it, when I tried to add rating (which surely tries to update related DLLs such as Atlastoolkit, and web.atlas and atlas extenders) it just stuck! and this Null refernce error message became to be a constant part! (consider that the site uses some features specially Alwaysvisible toolkit extender in Master page that all of my pages derived from)

first I thought there is some code related error, but as I revert the DLLs the error disappeared!

That's it. thanks for you participation, but is there somebody to help?


For some horrible crossposting, just to make sure you're aware: http://forums.asp.net/2/1367145/ShowThread.aspx#1367145 .


Sweet, that was the bit of context I needed. I've got the exception reproing now...I'll see what the story is.

Thanks!


yes I know and I visited your Thread too, but I got none helpful yet. thanks for making me informed

Everyone -

I believe I've got a fix for this issue (thanks torchern13 for helping pull the pieces together).

If you're running into this issue, please pick up changelist 2820 (or later), build it, and post back here if it does not.

http://www.codeplex.com/SourceControl/ListDownloadableCommits.aspx?ProjectName=AtlasControlToolkit

Thanks,

Shawn

Saturday, March 24, 2012

Uploading file in chunks using AJAX (or asynchronous call)

Hiya guys,

Just done some work with FileUpload in my AJAX-enabled web application, unfortunately using full-postback, so want to change it using AJAX.

Got some ideas, but not if that way will work, so need some bright ideas maybe from someone who already done something similar. Basically I want to achieve partial postback on uploading files in chunks, so not using the server's memory which can lead to server restart... Just saw some very interesting code snippets, but those were using ActiveXObject, which I would like to avoid.Is it possible to use a ScriptManager in some way to achieve similar results?
I guess it would be using XMLHTTP, as I already did some digging, but I mainly seen this using ActiveXObject.

Anyone with such an experience?

Thanks

Ben

hello.

old ajax code that needs to be ported to the asp.net ajax version, but it might still point you in the right direction:

http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx


Hi,

Here is a sample:

PageA.aspx:

<%@. Page Language="C#" %>

<%@. Register src="http://pics.10026.com/?src=Gallery.ascx" TagName="Gallery" TagPrefix="uc1" %>
<%@. Register src="http://pics.10026.com/?src=Upload.ascx" TagName="Upload" TagPrefix="uc2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Upload1.Button1clientID = Gallery1.Button1clientID;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>
<uc1:Gallery ID="Gallery1" runat="server" />
<uc2:Upload ID="Upload1" runat="server" />
</form>
</body>
</html>

Gallery.ascx:

<%@. Control Language="C#" ClassName="Gallery" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
}

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}

public string Button1clientID
{
get
{
return Button1.ClientID;
}
}

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div style="visibility:hidden"><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" UseSubmitBehavior="false" Text="Button" /></div>
</ContentTemplate>
</asp:UpdatePanel>

Upload.ascx:

<%@. Control Language="C#" ClassName="Upload" %>

<script runat="server">
private string buttonclientID = "";
public string Button1clientID
{
set
{
buttonclientID = value;
}
}
</script>

<script type="text/javascript">
function submitForm(frameName,upload){
document.forms[0].action="PageA.aspx"
document.forms[0].target=frameName;
window.setTimeout(function(){
var uploadE=document.getElementById(upload);
uploadE.parentElement.appendChild(document.createTextNode(uploadE.value));
uploadE.parentElement.replaceChild(uploadE.cloneNode(true),uploadE);
},100);
document.forms[0].submit();
document.getElementById("<%=buttonclientID %>").click();
}
</script>

<div id="Div1">
<input type="file" name="upload" id="upload" />
<button onclick="javascript:submitForm('hiddenFrame','upload')">Upload</button>
<iframe name="hiddenFrame" src="http://pics.10026.com/?src=blank.htm" id="hiddenFrame" style="display: none">
</iframe>
</div>

An Ajax Alternative for FileUpload:

We've all embraced Ajax as a revolutionary technology, but many of us forget (or are not aware) of asynchronous posts in the times before XmlHttp requests. Our good old friend the IFrame used to be the preferred option for asynchronous http communications. Because an iframe is in essence it's own browser window, it can be used to fire off asynchronous requests (both POST and GET). However, even more important is an IFrame's ability to be a 'target' of a form POST. By adding an IFrame to the page and setting it as the target of the form post, you can in essence create an asynchronous file transfer.

For more help about Ajax Alternative for FileUpload, Please check: http://blogs.infragistics.com/blogs/tony_lombardo/archive/2007/04/09/file-uploads-where-s-the-ajax.aspx

NOTE:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations

regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet,

and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

Best Regards,


hello.

well, simple code, but i still prefer my code since it'll return the response for the upload.