Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Wednesday, March 28, 2012

postback problem

Hi,

I have a control in my update panel which gets data from the database. The trigger for the update panel is a button control. its working fine ( i mean partial page update is happening) when i run my application.

But when this page is opened from an other user's browser, the whole page ( with all the other controls outside the update panel ) is being posted back on button click.

Any help is appreciated.

Hi developer_dotnet,

The same page has different behaviour in another users browser. Can you past your code here so we can analyze it. Thanks

Regards,


Hi developer,

developer_dotnet:

its working fine ( i mean partial page update is happening) when i run my application.

.

You mean in your development environment or you have published your website on this spot ?

developer_dotnet:

But when this page is opened from an other user's browser, the whole page ( with all the other controls outside the update panel ) is being posted back on button click.

First, suggest that we should use a debug tool such as Web Development Helper to make sure whether it make a asynchronous post or not.

If not , we should pay our attention to check if Asp.Net Ajax Extension V1.0 has been installed in the machine which host your website. http://ajax.asp.net/docs/InstallingASPNETAJAX.aspx .If Aajx ControlToolkit Controls used in your application, please add "AjaxControlToolkit.dll" to your bin folder.

If yes , please check the web.config settings .http://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx

If the problem cannot been resolved by doing these, please show your simple source code here.


I had a similar issue of partial postback. I have made it into a seperate <table> and it worked.


Hi all,

If an Ajax-Enabled page doesn't work properly in the browser, we may do some checking on the broswer security and privacy setting.

The following table lists required browser security and privacy settings for both user browsing and site development. In all cases, the recommended settings are the default settings for that browser.

Internet Explorer 6

Make sure that theInternet Zone in the Security Zones settings is set toMedium.

Internet Explorer 7

Make sure that theInternet Zone in the Security Zones settings is set toMedium-High.

FireFox 1.5 or later versions

In theTools menu underOptions, make sure thatEnable JavaScript is selected.

Opera 9.0 or later versions

In theTools menu underQuick preferences, make sure thatEnable JavaScript is selected.

Safari 2.0 or later versions

ClickSafari,Preferences,Security, and then Web Content and make sure thatEnable JavaScript is selected.

Hope it helps.

PostBacks are not working

Help!

As soon as I change to EnablePartialRendering="true" so that I can get all the fancy Atlas functionality the buttons stop working. Weird thing is that the project was working but now it does not. I've reinstalled Atlas and I still have the same issue.

The aspx code is:

<

atlas:ScriptManagerid="s1"EnablePartialRendering="true"runat="server"/>

<

asp:PanelID=panel1runat=serverHeight="140px"Width="475px">

<

atlas:UpdatePanelID="p1"runat="server">

<

ContentTemplate><asp:LabelID="lblHello"runat=serverVisible=false>Hello World</asp:Label><asp:ButtonID="Button1"runat="server"Text="Button 1"Visible=falseOnClick="Button_Click"/><asp:ButtonID="Button2"runat="server"Text="Button 2"Visible=trueOnClick="Button_Click"/>

</

ContentTemplate>

<

Triggers>

<

atlas:ControlEventTriggerControlID="ImageButton1"EventName="Click"/>

</

Triggers>

</

atlas:UpdatePanel>

</

asp:Panel><asp:ImageButtonID="ImageButton1"runat="server"ImageUrl="~/images/but_New.gif"OnClick="ImageButton1_Click"/>

The cs code is:

protectedvoid ImageButton1_Click(object sender,ImageClickEventArgs e)

{

this.lblHello.Visible = !this.lblHello.Visible;

}

protectedvoid Button_Click(object sender,EventArgs e)

{

this.Button1.Visible = !this.Button1.Visible;this.Button2.Visible = !this.Button2.Visible;

}

And the web.config file has the following (I didn't change anything on this)

<

controls>

<

addnamespace="Microsoft.Web.UI"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/>

<

addnamespace="Microsoft.Web.UI.Controls"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/>

</

controls>

Thanks!

Hey!

try this in your Page_Load:

Page.ClientScript.GetPostBackEventReference(

new System.Web.UI.PostBackOptions(this.(control that is not posting back));

I had the same problem, and this line did the trick. This generates the _doPostBack function everytime the page loads. I'm not sure why is this necesary...

hope this works for you!


hello.

i've copied your excerpt and it looks like it's running ok here...


OK so this is REALLY weird.

My atlas post backs don't work when the page fist loads, but once I refresh the page everything works great. I've compared the webpage source code for page when it works and when it doesn't and the source code is identical.

Anyone have any ideas.

Help!!!


I'm having the same problem. Does anyone have a solution?

Postbacks not working

OK so this is REALLY weird.

My atlas post backs don't work when the page fist loads, but once I refresh the page everything works great. I've compared the source for webpage when it works and when it doesn't and they are identical.

Anyone have any ideas?

Hi,

could you show us the relevant code?

Please see the following post for the code:

http://forums.asp.net/thread/1328373.aspx


hello again.

as i said, i've loaded the page and it is working here with or without partial rendering. hum...have you tried building a new web site by using the atlas template?


When I build a new web site useing the atlas template I get the same issue (Atlas only works on reload)

Sample Atlas projects I've downloaded (AtlasControlToolkit) seems to work fine.


hello again.

there's some weird stuff!!! btw, have you used fiddler to see what's happening during a partial postback?


Yes, fiddler isn't getting anything.

PRB: Master Pages and Update Panels/Script Manager - AJAX Magic not working

I have a master page that has the script manager control and a content place holder

I have a content page that is using the above master page and with a gridview control wrapped in an update panel

When the content page doesn't use master pages and the script manager is placed within the content page along with the panel, everything works fine

The problem arises when the master page has the script manager and thhe content page just has the update panel with the gid view. It seems to be doing a regular postback and the ajax plumbing doesn't seemto have any effect..

I also tried adding a page initi handler and specifying the trigger in the code behind but with no luck..

generated page source with script manager in master page is listed below. Why does gettting a common master page scnario be so difficult to getv it working..Please point me in the right direction

<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('_ctl0:ScriptManager1', document.getElementById('aspnetForm'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['t_ctl0:ContentPlaceHolder1:panel1'], [], [], 90);

//]]>
</script>


Genertated source when the script managersits on the page and the content page does not use any master pages

<script <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('aspnetForm'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tpanel1'], [], [], 90);

//]]>
</script>

Hi Ajaxnewbie,

Could you please post your code, so we can see how you have implemented it. Thanks

Regards,


Good question... I have exactly the same problem. I wish there would be a valid answer for this post.

thanks!

Pre-emptive Controls not working

I have installed Atlas the way the documentation says and am using VWD Express.
When I am in code mode, and type in <atlas: it does not pre-emp it and have the controls in the drop down. I'm not sure why? I finish manually entering it in, and receive no error. Not sure why this is doing it. Any ideas, or anyone had similar problems?

Mick

hello.

sometimes it takes a while to initialize the intellisense list here, but then it starts working without any problems.


yes, it does take awhile, today it is working perfectly!!
Thanks,
mick

Monday, March 26, 2012

Print button in ReportViewer not working inside UpdatePanel

The print button in the toolbar of the VS reportviewer does not work when the reportviewer is contained inside an updatepanel. Does anyone know of a workaround or fix?

My report parameters are dynamically specified via dropdowns and calendars, so they must be inside an updatepanel...

Hi

I had a similar problem. To overcome I disabled the print button in the reportviewer.

I then added a button, that needs to exist outside of the updatepanel, that on clicking the button triggers code to print to pdf

Works OK and the output capability, in my case, is limited to pdf

Hope that is of help

Michael


Thanks Michael. That seems like a possible solution for me... When you click the button, does it open up Acrobat or just bring up the print menu? Also, may I see the code for the button? Thanks!


Hi

I found the solution to this problem via the attached post. It opens up acrobat.

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=139828&SiteID=1

Also eliminates a new explorer window opening.

My code is:

ProtectedSub Button2_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

Try

Dim warningsAs Warning() =Nothing

Dim streamidsAsString() =Nothing

Dim mimeTypeAsString =Nothing

Dim encodingAsString =Nothing

Dim extensionAsString =Nothing

Dim bytesAsByte()

bytes = ReportViewer1.LocalReport.Render("PDF",Nothing, mimeType, encoding, extension, streamids, warnings)

Response.ContentType ="Application/pdf"

Response.Clear()

Response.ContentType = mimeType

Response.AddHeader("content-disposition","attachment; filename=Report." & extension)

Response.BinaryWrite(bytes)

Response.End()

Catch exAs Exception

EndTry

EndSub

This works for me. You will get an error though if the button is inside an update panel

Cheers

Michael

Saturday, March 24, 2012

Problem after upgrading from November 06 release to January 07 release.

I have a web site that was working beautifully with the November 06 release. I then upgraded to the January 07 release, and for the most part, everything is working as expected, with 1 exception.

I have a custom composite control which is basically a custom gridview that has a textbox column added at the end. The TextBox has a MaskedEditExtender. Both the TextBox and MaskedEditExtender are within an UpdatePanel. The GridView is also in an UpdatePanel. The idea is to have the GridView do paging via AJAX, and the TextBox update a shopping cart control with quantity without refreshing the whole GridView. The shopping cart is also contained in an UpdatePanel to reflect the new item added without a refresh.

First time the page loads, everything works correctly. If I then go to a different page of data, then enter a quantity in the textbox column for an item, I get the following javascript error:

Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method

I have confirmed that the TextBox's TextChanged event is indeed getting fired, but it dies with the above error at some point after that.

I am at a complete loss as to how to track down this problem. I would post my code, but there are several hundred lines of it for both the control and the page, and I didn't think it would be a good idea to try.

I would REALLY appreciate any help or suggestions on how to fix this, or at least, locate the source of the problem.

Thanks,

Alex

Just some additional info. As a test, I set EnablePartialRendering = "false" for my ScriptManager, and the site works properly without errors (but, of course, it now does a full postback).

Problem displaying AjaxControlToolkit website

Hi,

i've created an AjaxControlToolkit website (from a template).

to see that all is working well i've added a TextBox and watermark to it.

everything works greate here... at my computer... but...

when i uploaded it to my domain hosting space the toolkit is not functioning. all Ajax extension features are working but the toolkit features aren't!

and the "funny" part is that i don't get any error - client side nor server side...

any ideas?!?!?

i made sure the latest Ajax extension is installed on my host server and a restart to the machine was performed (even though it was not required)

any help will be appreciated...

Thanks!

Is the toolkit dll installed on the server correctly? Where is it located? In the gac or in the web app bin directory?
The dll is only located at my Bin directory. where else should it be?
Do a View | Source on the page coming off the server and compare it against the local version - that may help show what's not hooked up right.

Problem in Ajax i My ASP.Net WebSite

hi

i am working on my website.(when i created website,i don't select Ajax Enabled Template and it is a default asp.net website)

and i want add ajax feature to my website by drag ScriptManager and UpdatePanel from toolbox.but when i run my website,error shown in IE statusBar.

how to solve my problem ?

should i create new website as Ajax enabled template ?

thanks

Hello,

Make sure you install Ajax on your system, and you need to modify your web.config file.

The best way to modify the config file is, create new ajax project, which will built a web.config file for you.

You then compare your old web.config file with the ajax website web.config file. If you haven't added any information to your old web.config file, I would just copy the ajax web.config file to your current (web) project. And if you already added information into your web.config file, then just copy whatever you don't have from the ajax web.config file to yours.

I hope you understand what I'm talking about =)

WS

Wednesday, March 21, 2012

Problem in file uploading with Ajax

I want to upload an image on server. My source below is working well. But when I keep the same things in Update Panel it didn't work. Can some one help me on this strange behavior please?

Thanks!

ImageUpload.aspx.cs
 
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
 
namespace Articles
{
   publicclass Default : Page
   {
       public HtmlInputFile   Picture;
       public Label           Message;
       public Image           UploadedPic;
 
       publicvoid UploadImage(object sender, EventArgs e)
       {
           if (Picture.PostedFile !=null)
           {
               string PicType = Picture.PostedFile.ContentType.ToString();
               if (PicType == "image/jpeg" || PicType == "image/gif" || PicType == "image/pjpeg"
                   || PicType == "image/bmp")
               {
                   try
                   {
                       string PicName = Picture.PostedFile.FileName;
                       string NewPicName = (string)Session.SessionID + "_" + PicName.Substring(PicName.LastIndexOf(@dotnet.itags.org."\")+1);
                       string UploadPath = Request.PhysicalApplicationPath + @dotnet.itags.org."\Upload\";
 
                       Picture.PostedFile.SaveAs(UploadPath + NewPicName);
 
                       Message.Text = "Picture successfully uploaded to server!";
                       UploadedPic.AlternateText = "Uploaded picture...";
                       UploadedPic.ImageUrl = UploadPath + NewPicName;
                       UploadedPic.Visible =true;
                   }
                   catch (Exception exc)
                   {
                       Message.Text = exc.ToString();
                   }
               }
               else
                   Message.Text = "File format not supported!";
           }
       }
   }
}

ImageUpload.aspx
 
<%@dotnet.itags.org. Page Language="C#" Codebehind="ImageUpload1.aspx.cs" Inherits="Articles.Default" %>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Image Upload #1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
 
<h3>Image Upload #1</h3>
<form enctype="multipart/form-data" runat="server">
   <table>
       <tr>
           <td>Image:</td>
           <td><input id="Picture" type="file" runat="server"/></td>
       </tr>
   </table>
   <br/>
   <input type="submit" value="Upload >>>" onserverclick="UploadImage" runat="server"/>
</form>
 
<asp:label id="Message" runat="server"/>
 
<hr>
 
<asp:image id="UploadedPic" visible="False" runat="server"/>
 
</body>
</html>

Hi,

unfortunately the FileUpload control, like some other controls, don't work together with the UpdatePanel. So no go.

You can check the controls out that don't work with it here:

Taken from the documentation:http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx

Controls that Are Not Compatible with UpdatePanel Controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.

problem in implement ajax component

hi guys,

i m shaikhu. i try to implement ajax components . i start from ajax drag panel , i make it and it's working but when i drag and place panel in my page it go again it' default position not stay anywhere in my page .

what's fault.

Hi,

the DragPanel uses the BODY area as the drop zone. This area is determined by the layout of the page, but you can enlarge it using CSS:

body { height:600px;}

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.