|
Tyrone Watt wrote: Is there anyway to save the state of dynamically loaded controls?
Sadly, your controls need to be created BEFORE page load, in order to participate in the reconstruction of the viewstate tree. Otherwise, the values are dropped. The alternative, is to store a hidden field in your page, and have javascript store the state of controls in that, because then you'll have something to set the state with, when you recreate the controls.
Tyrone Watt wrote: Also, is it possible to tell which dynamic user control fired the postback?
Same issue, really. No click event, unless the control existed before page load.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi
Thanks for that.
I have no problem creating the controls in PageInit instead but either way that doesnt seem to be the case.
The click event fires correctly after the page load, and the viewstate is set correctly in the "onclick" event, but it is not set in the page_load. So somewhere between the page_load and the onclick the viewstate is set back. Problem is I need to do things based on that viewstate before the click event or regardless of whether a click event occurred at all.
With the second question, maybe i didnt phrase it correctly. What I need to know is which particular control fired the postback in the page_load. So if i have 6 user controls on a page and control 3 fired the postback. On the page_load for the page and all 6 controls is there a way to tell that it was control 3 that did the postback, or is a javascript hack with a hidden field the only way.
As the event fires in the correct control, surely the must be some means of knowing which control fired the postback rather than just knowing that a postback occurred from one of the 6 controls.
Thanks
|
|
|
|
|
1 - if you create the exact same control tree, viewstate should be restored
2 - yes, I got that. If you have viewstate, then the sender property of the event is passed the control that fired it, so you can access it that way. In the absence of viewstate, you don't get an event at all. As soon as an event fires, cast the sender to the right type and then identify it from there.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
1. Thats what I thought, but its not... And as you mention in 2
Christian Graus wrote: In the absence of viewstate, you don't get an event at all.
Which puzzles me because the event fires, but the viewstate property is still null.
With 2, the "sender" in the onload is always the control itself, so unfortunately that doesnt help. Its in the onload that i need to know which control fired the postback, not in the onclick event(where the sender is the control that fired the event).
Thanks for you input so far, do you have any other suggestions i can try. Been beating my head against a wall for a while on this now and its starting to hurt...
|
|
|
|
|
Hi.. i want to convert datatime format to Date...i want to display On UI only date...
I am using below method its not working for me...
can anyone suggest me..
<br />
public static String GetShortDate(String sDateTimeValue)<br />
{<br />
return String.Format("{0:dd/MM/yy}", sDateTimeValue.ToString());<br />
}<br />
|
|
|
|
|
public static String GetShortDate(String sDateTimeValue)
{
DateTime _date = DateTime.Parse(sDateTimeValue);
return _date.ToString("d", DateTimeFormatInfo.InvariantInfo);
}
Have a look at the various formats here[^]
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
modified on Tuesday, June 23, 2009 4:09 AM
|
|
|
|
|
Hey..i tried with above method..i followed other methods also which you send me ..i,e very good link for beginners like me....eventhough i couldn't resolve that issue..
its throwing exception error like below..
FORMAT EXCEPTION UNHANDLED BY USERCODE...
converting from string to datetime parse the string to take the date before putting each variable datetime object into
How can i resolve ???
|
|
|
|
|
Hello,
Thank you for reading this post. Here is my situation. I am new to AJAX development. I have a gridview with 4 boundfield columns and 1 buttonfield column. I need to display a popup anytime a user hovers over the buttonfield column and popup a panel which has some database driven text and a button which says "Add this to my plan" and a cancel button on the popup. How do i associate a hovermenu extender to a buttonfield column with targetcontrolid? Does the hovermenu controller need to be associated in the rowcommand of the gridview? How does this need to be done. A code sample or a URL where someone has already done this will help my cause mightily ! Here is the code of what I have
<asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<ASCPWebC:GridView
ID="gvProducts" runat="server" DataSourceID="odsProducts"
OnRowDataBound="RowDataBound" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
CssClass="datatable" CellPadding="0" CellSpacing="0" BorderWidth="0" GridLines="None" >
<Columns>
<asp:BoundField DataField="FieldA" HeaderStyle-CssClass="first" ItemStyle-CssClass="first" DataFormatString="{0Big Grin}" HeaderText="Field A" SortExpression="ORDER_DATE" />
<asp:BoundField DataField="FieldB" HeaderText="Field B" SortExpression="FieldB" />
<asp:ButtonField CommandName="SelectDescription" DataTextField="FieldC" HeaderText="Field C" SortExpression="FieldC" />
<asp:BoundField DataField="FieldD" HeaderText="Field D" SortExpression="FieldD"/>
<asp:BoundField DataField="FieldE" HeaderText="Field E" SortExpression="FieldE"/>
</Columns>
</ASCPWebC:GridView>
<asp:Panel ID="Panel1" runat="server">
<% --Here is popup panel,this needs to have some text and an add button,cancel link -- %>
</asp:Panel>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cblTest" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Any and all help is much appreciated.
Thanks
RH
|
|
|
|
|
I have developed a test website in vstudio 2008. I published the site to http://localHost/WebAndASP/
I run the Web program in IDE and it opens up browser window to
http://localhost:3400/ and displays my page
I can also open up a browser window manually type in the above and view the page.
However I cannot do http://localhost/WebAndASP/Default.aspx
IIS has Website entry named WebAndASP. It is configures with low priority. The directory security is set to Anonymous access and Integrated Windows Authentication
When I right click on the Website node in IIS(5.1 btw) I get the same http 500 internal server error message.
Strange that it can execute with the :3400 but not locally.
I would like IIS to work without having to supply the :3400 or any of the other values
Help is greatly appreciated
Dale
|
|
|
|
|
How did you deployed your application on IIS ? Can you please check in which Port your web sites is running ? By default it should be 80.
Thank you !!
|
|
|
|
|
Yes its port 80
The port numbers assigned are random, based on what VStudio decides to use for its virtual server.
however once I publish the web app to the wwwroot directory, http://localhost/AppName should be all thats required, to the best of my knowledge.
|
|
|
|
|
We are moving to .NET slowly. We have an ASP.NET log-in/admin that has links to multiple ASP 3.0 sites. The problem we are having is the session timeout. I can not figure out a way to update the clock on the .NET side. Most of our users will use the Legacy side until we slowly convert them over. We decided that making a response.redirect specific "ping" pages in ASP 3.0 and .NET will not be a good solution. We have many independent sites that we are going to tie into this .NET "hub". But recoding all of the sites to use the "ping" solution is not what we are currently looking for. Right now I just set the .NET timeout to 60 min and hope for the best. Has anyone had this problem? What was your solution? Any suggestions?
Thank you in advance!
|
|
|
|
|
Seems the two sites are completely independant you'll struggle to keep the .net session alive if you user isn't actually on that site. You could possibly create an isapi filter that all requests to your legacy site go through which will automatically redirect to a page on the .net site that can direct back out to the legacy site again.
|
|
|
|
|
Thank you for your reply.
I am still trying to find another solution.
We have played with the redirect but it seems like there has to be a better solution.
Right now we just increase the .NET session.
Thank you again.
|
|
|
|
|
I'm trying to create an automatic test on different page-types. But I do not succeed in creating a page-instance with its controls. Do anyone know how I can solve it.
I have tried this:
Type pageType = Page.GetType();
Page newPage = (Page)pageType.GetConstructor(new Type[0]).Invoke(new object[0]);
if (Page.Controls.Count == 0)
{
throw new Exception("No controls");
}
I get the controls if I call the processRequest-method like here below but this method executes the page and that is not a optimal solution. I only want to get the controls and not execute the page. Is there a way to solve it?
Type pageType = Page.GetType();
Page newPage = (Page)pageType.GetConstructor(new Type[0]).Invoke(new object[0]);
newPage.ProcessRequest(HttpContext.Current);
I have identified that the controls are created somewhere after the InitializeCulture-method and before the OnPreInit-method. But as I said I have problems in finding the method that creates controls. Do someone have a clue?
|
|
|
|
|
Controls are actually Web is working only using Request and Response.
It is better to use invoke a request to find the processed value.
When you call the constructor the objects will be created but it will not be added to the Control Collection. I think there must be one event (I have to look) which does this for you before and also calls PreInit.
I need to take a look on the DLL it produces and use Reflector
You can also try that. But why do you want to create object of Page.. when you dont want response to be sent to the client.
asp.NET calls an HTTPHandler, so when you create any handler it calls its processrequest and the process automates. Page is also a Handler so it calls its processrequest to get the response.
Hope you understand.
|
|
|
|
|
Thank you for your answer! The method that adds the controls to the control collection is pretty hard to find I have tried to find it for many hours now with reflector but it's not easy. If you find it I will be very glad!
The reason I want to get the controls is to create a automatic test that validates the mapping between the domain entity and the page.
|
|
|
|
|
Hello guys,
I'm creating a very basic CMS which contains a File-Explorer. In this explorer it's possible to select an File from a ListBox, and do several options with the file then. My problem is: I have told the ListBox todo a Postback, but everytime this Event is fired my function isn't able to get the selected item, I get nothing.
Protected Sub ListBoxDir_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBoxDir.SelectedIndexChanged
If ListBoxDir.SelectedItem Is Nothing Then
ErrorMessage.Text = "An error occured!"
Exit Sub
End If
End Sub
I always get the error.
By the way: I'm using Visual Web Developer 2008 Express (That shouldn't mind), AND I've button the Listbox into an UpdatePanel:
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<!--Many Buttons, Textboxes etc., and the Listbox are here.-->
<EndingTags for all the AJAX-Stuff>
I didn't forgot to enter a ScriptManager.
Everything seems so weird...
|
|
|
|
|
Try loading the listbox during page load and under if not is postback(uuor code). At what point do you fill list box?
|
|
|
|
|
Thank you! I filled the Listbox at Page_Load. I now limitted the Filling just on Page.Postback=false and it's working great now!
|
|
|
|
|
Any one with question conserning crystal reports 10 with oracle and asp.net? I wanna answer them now live
|
|
|
|
|
Dont need such messages.
|
|
|
|
|
Hi,
Can TFS2010 do the parallel Db restore.if possible How it can be ...
Thanks
Anand
|
|
|
|
|
How is this in any way related to ASP.NET
only two letters away from being an asset
|
|
|
|
|
Its all about in Build,Deploy in Lab management
I need it for automated Deploy without custom code.
|
|
|
|