Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Wednesday, March 28, 2012

Extenders inside templateColumn in RC1

Hi, I have just installed the new RC1

I have a gridview that contains a template column, with 2 imageButtons inside it (Basically Edit Item and Delete Item) and a confirmButtonExtender linked on the delete image button. Everything was working well in Beta 2, but in RC1, in design time, it does not render the gridview, saying that a scriptmanger is required and must exist before any control on the page... It works great at runtime, but it is quite annoying at design time...

Will this be fixed in a future release of the control toolkit?

Thanks!

Yes, I am experiencing the same issue as you but with a PopupControlExtender inside a FormView on a ContentPage.


Please reply with acomplete, simple, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

Hi David, This is a very simple page that demonstrates the error I am getting (only at design time, by the way). I have started a new project using the template provided by Ajax (Ajax Enabled web application), and just dragged a gridview, and edited the templates..

Thanks!

Default.aspx

1<%@. Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXEnabledWebApplication1._Default" %>23<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>45<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">67<html xmlns="http://www.w3.org/1999/xhtml" >8<head runat="server">9 <title>Untitled Page</title>10</head>11<body>12 <form id="form1" runat="server">13 <asp:ScriptManager ID="ScriptManager1" runat="server" />14 <div>15<asp:GridView ID="GridView1" runat="server">16<Columns>17<asp:TemplateField>18<ItemTemplate>19<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Testing"20TargetControlID="Button1">21</cc1:ConfirmButtonExtender>22<asp:Button ID="Button1" runat="server" Text="Button" />23</ItemTemplate>24</asp:TemplateField>25</Columns>26</asp:GridView>2728 </div>29 </form>30</body>31</html>32
 
Default.aspx.cs
1using System;2using System.Data;3using System.Configuration;4using System.Collections;5using System.Web;6using System.Web.Security;7using System.Web.UI;8using System.Web.UI.WebControls;9using System.Web.UI.WebControls.WebParts;10using System.Web.UI.HtmlControls;1112namespace AJAXEnabledWebApplication113{14public partialclass _Default : System.Web.UI.Page15 {16protected void Page_Load(object sender, EventArgs e)17 {1819 }20 }21}22  

This seems like an atlas issue and not a toolkit issue. The script manager is not being detected at design time. Could you try the asp.net ajax forum?

http://forums.asp.net/1007/ShowForum.aspx


I tested to define a asp:TemplateField template of a asp:GridView in Ajax RC 1.0 and get the similar problem saying "There was error rendering the control.The control with ID 'ConfirmButtonExtender1' requires a ScriptManager on the page.The ScriptManager must appear before any controls that need it". Wish this issue will be resolved in ASP.NET AJAX RTM.

Hi,

I too was experiencing this issue, however as a workaround i have put the extender into a usercontrol, and then put that into the template column. This way the gridview looks ok at design time, and it all compiles properly at runtime too.

Hope this little snippet of info is useful to someone else who has been searching for this issue.

Cheers,
Rich.

Extenders and windowed control problem

Hi,

we are using a couple of extenders such as the Calendar extender, Autocomplete extender etc...

The problem with those is when the form contains windowed controls such as the select box just below them... in that case, the usual "problem" of seeing the select through the extender div happens.

Before today, we were building our forms by keeping that in mind... making sure to avoid such positions. But now, our system should allow external people to define forms; which has quickly led to the above problem...

There is a workaround to this problem, using an empty iframe positioned right below the div; but is there any way to have extenders do the same to avoid the problem ? (as this problem is quite common, we think it is weird that it is not part of the extender functionality)

Thanks

/Tharn

ok, issue closed. They actually do it; but it does not work anymore as soon as controls are in relatively positioned elements.

I'll better report that to the codeplex project.

/t

Monday, March 26, 2012

Execute JS Code onload and on partial postback

Hi All,

I have a ScriptManager tag that contains a script reference to a JS file; "test.js." Test.js contains a function that needs to be executed on the application's loadand on a partial postback.

The reason that it needs to be executed on the application's load event is because if I execute it just using RegisterStartupScripts the script isn't present on the page yet because it is being controlled by Atlas.

So, I create a wrapper function for statement on the fly and I register it to execute on the application's load event. I.e. "Sys.Application.load.add(wrapperFunction);"

That works great the first time through when the page is loaded because the application's load event fires. However, how do I get the same execute statement to fire on a partial postback? The only workaround I have right now is to get a handle to the current ScriptManager and test to see if it is InPartialRenderingMode. If so, I don't do the add to load code, but I just register a startup script instead.

Is there a nicer, easier, cleaner way of doing this.

Thx!!Hi,

I think I have a decent workaround for the moment. My example I was providing was a bit simplistic in comparison with what I actually need to do. I actually needed to completely change what JavaScript commands were executed and their parameters for each time a server side control was loaded. Having said that, the best way I've come up with so far is test on the backend if my ScriptManager is in PartialRenderingMode and handle it accordingly. If it isn't, I use the load event and attach a delegate to execute. If it is, I just execute a the function that was to be the delegate. It's not the prettiest code, but it works reliably and can be repeated for other controls.

Thanks for your help on this.

I need to do the same thing. How did you get it done?

I have a myfuncs.js in the script manager.

I want to call a function in the js file after a updatepanel psotback.

I can not find a good way to fire it. I thought Application.Load would do it but the page only gets loaded once.

and ideas?


I kind of do what I described a few posts back.

I test to see if the control's ScriptManager is in PartialRenderingMode and if so, I just emit the JavaScript straight to the client using the ClientScriptManager.RegisterStartupScript method. If it is not in PartialRenderingMode, I wrap my JavaScript in a function and add it to the Sys.Application.load event and then emit the whole code block to the client again using the RegsiterStartupScript method.

Ex of what it would look like on the client.

function WrappedFunction() {
var x = new Array();
x.push(1);
}

Sys.Application.load.add(WrappedFunction);

OR

var x = new Array();
x.push(1);

HTH

hello.

since the file is already loaded, how about adding an event handler to the propertychanged event and check? there you could check the property that's changedand if it's the inPostBack property and its value is false, you know that you've just finished loading the page. btw, why can't you use the registerstartupscript method? i don't understand what you mean when you say that the script is being controlled by atlas...


Hi.

By "script is being controlled by atlas" I mean that the script file is registered with the ScriptManager.

I.e.
<atlas:ScriptManager ...>
<scripts>
<atlas:ScriptReference path="test.js" ...>
</ ..>
</..
The reason that the script needs to be registered with Atlas is that the function I need to execute on startup and postback has code within it that relies upon the Atlas Sys namespace and therefore must be loaded after the Atlas scripts have been loaded otherwise it'll throw an error complaining it doesn't know what Sys is. (The statement also relies on user input which is the reason it needs to get reexecuted on postback.)

It is my understanding that the page processes any <script ...> tags including any startup scripts first; then loads the Atlas scripts; then loads the scripts that are defined within the ScriptManager Scripts tag.

So, if I just use the RegisterStartupScript method and my scripts are registered with the ScriptManager, my startup statement will execute before the Atlas files (and my custom js file) have been loaded and throw an exception. My code needs to wait for the Atlas files and my custom js file to load before executing so instead, I add the startup statement to a function and add it to the Sys.Application.load event delegate as an event handler. This way it'll wait until Atlas has loaded before executing.

This works fine for the load, but one of the function's parameters is based upon user input and the function needs to be reexecuted whenever the page is postbacked.

The first time through the code looks like

function wrapperFunction () { testFunction (''); }
Sys.Application.load.add (wrapperFunction);

But, on postback the same part of the code would look like

function wrapperFunction () { testFunction('30111'); }
Sys.Application.load.add (wrapperFunction);

Of course, the second code block doesn't do anything on postback because the load event has already fired. To accomplish the same thing on postback the code would just look like:

testFunction ('30111');

as the test.js file where testFunction lives has already been registered and now can be accessed through startup scripts.

(All code blocks are registered to execute on startup.)

I'm not really seeing how I can do what you suggested and add an event to the PageRequestManager as my function call needs to change based upon user input.

So I can test for InPartialRenderingMode in code behind and modify the startup JavaScript accordingly (which is what I'm currently doing), but it seems that there needs to be an event that covers both loading initially and loading after a postback. Emitting a pure JavaScript function call works for postbacks and attaching to the load event of the Application works for loading initially, but I'd like to be able to write one piece of code that works for both cases.

Phew ... I hope that's at least partially clear.

Thx for any and all help.

hello.

yes, now i understand.

handling the propertychanged of the pagerequestmanager is the only way i know to handle the end of partial postback.

what you could do is inject a global variable with the value that you need to pass to your jscript function; since the registerXXX inserted method will be called before the event being fired, you can be sure that the global variable will allways be correctly set up.


To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal
To call specific javascript function or register a new javascript after the update panel partial postback

you can use my custom made control

to download it and to know how to use it

visit my blog.

http://go2amitech.blogspot.com/2010/08/running-specific-javascript-after.html[^]



Amit Panchal

Saturday, March 24, 2012

Exception During Exporting Data From GridView to Excel File

Hi ,

I am Using Update Panel in my page and this Update panel contains lots of server side controls including GridView ...

Well, i want to Export Data from GridView to Excel or PDF file ... But its not working properly ...

The Code is ...

Response.Clear();

Response.AddHeader("content-disposition","attachement;filename=" +"IFR" + System.DateTime.Now +".xls");

Response.Charset ="";

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.ContentType ="application/vnd.xls";

StringWriter stringWrite =newStringWriter();

HtmlTextWriter htmlWrite =newHtmlTextWriter(stringWrite);

gvReport.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();

The code written is correct but it gives Exception on Execeting the line.. gvReport.RenderControl(htmlWrite);

Exception = < Control 'gvReport' of type 'GridView' must be placed inside a form tag with runat=server. >

And all the controls including GridView are inside the form tag.

Please Help me out to fix that problem i shall be very thankful 2 u.

Its gud if u reply the solution on ... irfan623@dotnet.itags.org.hotmail.com

Thanks .

Irfan Gull

Hi There,

You can't use Response.Write inside of an UpdatePanel.

Why? Because Ajax updates are done using XMLHttpRequest which exchanges xml with server. Resonse.Write adds some string in xml and the xml parser on the client has no idea what to do with such a xml.

Hope it helps!


Basically the Error is at

dgFailureReport.RenderControl(htmlWrite);

When this line executes than Exception occurs...

There is no problem with response.write ...

the problem is with only the above one line code...

Let me paste the code again here... am still having that problem please someone help me ragarding this... thanks in advance...

Response.Clear();

Response.AddHeader("Internal Failure Report","attachement;filename=" +"IFR" + System.DateTime.Now+".xls");

Response.Charset ="";

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.ContentType ="application/vnd.xls";

StringWriter stringWrite =newStringWriter();HtmlTextWriter htmlWrite =newHtmlTextWriter(stringWrite);

dgFailureReport.RenderControl(htmlWrite); // Here Exception Occurs.

Response.Write(stringWrite.ToString());

Response.End();

Wednesday, March 21, 2012

Events & Atlas enabled Custom UserControls

I've got a UserControl I use to search for a customer. This UC contains a ScriptManager and an UpdatePanel.

Just for simulation I've created a page containing 2 of my UC's, this generates an error saying :

Only one instance of a ScriptManager can be added to the page.

If I use only 1 UC on the page I'd like to inform the Page that a Customer was selected so I try and raise an (public) event but that results the little error icon on the bottom left corner of IE saying 'error on page' Details: Line:40, char:1 Error:Object expected Code:0URL:http://.../default.aspx

I can imagine that since this selection/postback is done from within an UpdatePanel, the rest of the page cannot be 'reached' by the event and that would cause an error. If I remove the UpdatePanel things work just fine...

What would be a good way for an Atlas enabled UserControl to 'talk' to the page (or UserControl) on wich it is currently begin used.

Regards,

Jurjen.

Hi Jurjen,

To use two UserControls on the same page put the Atlas Script Manager Proxy tag in the Usercontrol insted of ScriptManager tag and add the ScriptManager tag in the page which uses this UserControl. I think this would solve your first problem.

Regarding the second could you please explain in detail what you are doing and what is to be done.

Thanks & Regards,

Event triggering. Same problem. exposed differently.

Greetings. I will reformulate my problem in hope someone can give me a lead on it.

1) I have two textbox, that will contains dates.

2) They both have an MaskedEditExtender and a MaskedEditValidator attached to them to validate the proper date format.

3) A CalendarExtender is also linked to each of the text box.

4) Everything works fine, EXCEPT now, somehow, for some dark and unknown reason I haven't figured out yet, there is now no way of triggering the "onTextChanged" handler of the textboxs. Even if I don't use the calendar to enter the date and I type directly in the textbox, no event is triggered at all.

So my question is : Does anybody know what is wrong ? Seems to me that the MaskedEditValidator is taking over and not letting the onTextChanged event being broadcast. If that's the case, is there any workaround or any way to trigger an event when new text is inputed ?

Thanks a lot.

I am having the same problem (with the onTextChanged not firing).

I have a texbox and a calerdarextender within my gridview. I currently have an add button in each row that the user clicks to submit the chosen date, however I need to change this to make it work so that the row is added automatically when the user selects a date and the textbox text is changed. This textchanged event never fires...any ideas on how I can achieve this result while using the calendarextender control?

Thanks...