C# - Dynamic Ashx Stylesheet Not Always Working On Postback?
Feb 18, 2011
I have a site when the customers can add their own style rules to their websites. The whole process works perfectly, but when they page with the dynamic stylesheet posts back, sometimes only some of the stylesheet rules load. The initial page loads all of the styles, and some postbacks it loads fine as well, but on some of the postbacks (about 60%) certain styles randomly get dropped. Is it a lifecycle issue? Its so random, I have nothing to trace. Is there a way to load the dynamically generated stylesheet and persist it throughout the session, then dismiss it?
I'm making a new design for my website, but I want to keep the old one and possibly switch between the two.
Unfortunately, I've changed the content on the Master Page (luckily I have a backup). What I was thinking was to keep separate master files for each theme, and then just determine which one to server based on which stylesheet is loaded.
The only way I can think to do this is to keep a "settings" file on the website that has a "stylesheet=1/2/3/4/etc" line. Depending on the number there, the server will serve the correct master page.
Alternatively it might be easier to do something similar, but instead of serving a whole different master page, set a specific stylesheet to use.
I can read a text file (even encrypt/decrypt a file before and after it gets read for security), but actually giving the server the instructions based on what is read is where I'm lost.
In the page element of my Style sheet, I have the width set to 1100 pixels. In VS, it works perfectly. When I debug it, no problem. But when I publish it to IIS, it reverts back to the default... 960 I think.
CSS Code: .page{ width: 1100px; background-color: #fff; margin: 20px auto 0px auto; border: 1px solid #496077;}
I have created .ashx which implemented IRequiresSessionState, so I can create session variables in that ashx, it worked in IE, but doesn't work in Firefox.When access this session variable from other pages it's NULL.
you save data into a dynamic hidden field ,which is created dynamically during the handling of some postback event.what is the best way to retrieve it from this field upon a postback, (besides searching the request for the key of this hidden field and then retrieving the corresponding value as in the code below)?
protected void Button2_Click(object sender, EventArgs e) { bool found = false; for (int i=0; i<this.Request.Form.Keys.Count; i++)
I have an ASP.Net Application that in some cases will create up to 100 or so dynamic controls that have events being triggered from CodeDom Assembly. The problem is when at an event is fired off I have to Re-Create all those controls on a PostBack. With 10 to 30 controls its not so bad but with 100 it takes approx 3 to 4 seconds before the user can resume filling out the rest of the controls.
In this instance I can't load the datagrid in page_init as the results of the datagrid are determined by a checkbox and the checkbox would always be set to true during page_init to the viewstate not being loaded.
I have an OnItemDataBound event on the datagrid that dynamically creates controls and later on I want to access the value of some of these controls (e.g. a text box)
Of course the problem is I can't access these controls values as they don't persist over a postback.
As the title says , i'm looking for some kind of technology that allows me to dynamicly add & remove usercontrols.Without a postback ofcourse :)A link would be awesome , example code would be super!
I have a page to wich I had several controls dynamically. When the page is posted back via Ajax, the values of the dynamically control do not make it server side. However, everything works well if the page is posted back in the normal way ( without Ajax).
I need the post back to be done via Ajax because I need to use the Callback function to perform other tasks in the UI once the call returns.I found this excellent article but it doesn't discuss ajax:
I'm trying to create a page that will display a survey that has multiple pages... everything displays fine, but I'm doing something wrong on the timing as my dynamic controls (for the answers) are disappearing when I post back. (so I can't get the answers or perform validation)
1) I have a Repeater control on my page that is populated in Page_Load !IsPosBack that is acting as navigation. It displays each page name, and each Repeater Item contains a LinkButton whose OnCommand event does:
2) There is a second Repeater on the page that is populated with Questions corresponding to the selected Page (from the step above) This is just a DataTable created and then DataBound to the Repeater.
3) The Questions Repeater control has an OnItemCreated event that dynamically generates the proper control for the Answer (TextBox, DropDownList, RadioButtonList, etc...) and places that control in a Placeholder in the Repeater Item.
This all works for displaying, but when I attempt to click a Button, I cannot access the controls generated in step three, and all of those controls disappear from the Repeater.
I have tried creating databinding the Questions repeater in Page_Init as well as dynamically creating the answer controls in a (foreach RepeaterItem...) statement as opposed to OnRepeaterItemDataBound... but now my buttons (located in the FooterTemplate) refuse to post back at all...
added a Test button for postback, but that doesn't work either.
I have created a dynamic table using user entered values for Rows and columns. After the table is created the data is populated on the table. I have a separate event that is clicked to retrieve this data, but I am not able to get this data upon postback.
I need to convert the table values (in int) to an array for further processing.
I know this topic has been posted before but I'm stuck on it still.I've placed creating of dynamic control on Page_Load but the event isn't firing.On my asp page, i have <asp:PlaceHolder ID="test" runat="server/>On my code behind, I have private display method.
private void DisplayButton() { LinkButton btn = new LinkButton(); btn.ID="unit_1";
I have a asp.net page with a button, the event the button needs to perform on it's click event needs to vary, dependant on what options are selected further up the page. The button itself is included in the master page, and it's actions are affected by selections made in the child page.
To do this, I have a method in the master page, that is called by the child page, when a users presses a button, that passes the Eventhandler to be used by that button, that is then assigned to masterpage eventhandler for that button:
public void assignEvent( EventHandler saveEvent) { this.SaveButtonEvent+= saveEvent }
Then, when the save button on the master page, it calls that eventhandler
The event handler is assigned ok in the first section of code, however because pressing the save button causes a postback, the SaveButtonEvent event handler is set back to being null, and so nothing happens.
How can I preserve the contents of SaveButtonEvent Event Handler during postback, or is there a better way to be doing this?
EDIT:
I can get this to work by saving the EventHandler to the session, but this doesn't seem like a great idea.
I'm inserting controls dynamicaly on my page on pre-init, thease controls are inserting based on a dropDownList that load its values from a database. These values are diferent to all clients.
If I insert my controls on pre-init then I have access to the value of radiobuttons, but this insert only 1 controls cause in pre render I don't have the selected value of dropDown.
If I insert my controls on on-load event then I have the value of my dropDownList control so I can be able to inser the correct number o controls but I don't have the value of my auto-postback radioButtons.
I make a project to solve this and I share the code of it here. (VB.Net 4.0)
I am working with a user control which is inside an UpdatePanel. The user control uses swfobject to add a flash object to a div in the user control. Part of the functionality of the user control is it allows the user to change 'channel'. The channel is set and handled in the code behind hence the call in the JavaScript below to <%=channel%>.
The problem I have is that when the new channel is saved, the JavaScript code below is still pointing to the old channel. The only way I can fix this is to refresh the page via the code behind, but I'm thinking there must be a better way to do this..
Now I inserted some html content inside this div on some button click(without postback) . Now when I perform a postback on some action say on server control submit button , I want the html(which I inserted via javascript) be persisted in the foo div. Right now I am thinking to take an hidden input server control and when the form will be submitted I will insert the content of foo div in that hidden control, the next time when the page loads after the postback I will fill the foo div with the content inside the hidden field. Am I going with correct approach or is their any other good approach which I should opt ?