FreeTextBox only populates after page refresh - asp.net

Im using "FreeTextBox" for users to edit web content (ASP.NET VB)
I query the database on pageload and set:
FreeTextBoxFoo.text = dbFoo.GetValue(2).ToString()
This DOES return the correct string data if I write it to an asp:Literal for example.
However nothing shows in the text box, until I refresh the page (F5)
Now in running the application in Visual studio in debug, it works ok.
So where is this string data getting lost, or hung? is it being loaded into the textbox but not displayed until a postback??
ETA: I forgot to mention this is inside an ASP:AccordionPane
Added more...
It seems that if I put the textbox outside the accordion panel, then it populates ok, so might be something to do with the order of execution?

Related

Access imagebutton src in postback

Environment: Microsoft Visual Studio 2019 Community, ASP.NET v4.8 web application project using VB.NET
Problem: I have an asp imagebutton which is used to indicate a status by changing the image each time it is clicked (red-amber-green-red). This is done using javascript:
btn.src = newImage;
This works fine. The imageurl is accessed using src in the html but the image is initially set in the code behind databind by setting the imagebutton.imageurl:
btn.ImageUrl = initialImage
On a postback (a save) I want to find the status by looking at the current imageurl.
Dim btn As ImageButton = CType(mainGrid.Rows(i).FindControl("btn"), ImageButton))
someval = btn.imageurl
The problem is that imageurl shows the value initially set, not the changed value. This weirdness seems to point to a bug in my code somewhere as obviously the imagebutton variable in the save code behind knows nothing about the imagebutton variable in the databind code behind.
Can someone confirm that imageurl in the postback should in fact match the changed src in the html?
Edit: I should say that I don't want to use server-side processing each time they click the imagebutton. I can make this work using a command argument BUT that leads to a database write every time they click. There are a dozen or so buttons on each row so I think that would be pretty slow in production.
The answer, provided by Albert D. Kallal, is that imagebuttons don't pass any changed attributes back to the code behind. Possible solutions are to 1) use an update panel, 2) change a paired hidden field at the same time (of a type that does pass the change back) or 3) use ajax to update the db after the change. I used option 3.

HTML Select Not Showing Selected Option After Refresh in Firefox

TL,DR: Firefox (and only Firefox) fails to display the right select child element as marked with selected="selected" upon clean refresh of a page, even though it is correct in DOM (but only under certain conditions).
(I do not believe this is a duplicate of HTML select, correct option selected in DOM, but wrong item shown in firefox as I am not using ember.js.)
Background
I'm building a "software management/update server" in ASP.NET WebForms. It stores master copies of applications and serves downloads and updates via a simple API. Each application (or "App" as they're referred to in-code) has a DeptID and a GroupID, which are GUIDs, relating to respective Dept and Group tables. Each Group has a DeptID field also.
On one particular page, used for editing a chosen software application's details, NON-postback requests (.e.g., http://localhost/admin/app/edit.aspx?id=guid-here) will result in calls to the database to populate field data on the page.
In brief, the ASP.net runtime Page_Load event does the following:
Ensures that this load is not a Postback
Verifies than an id parameter was provided in the query string
Populates options in the ddlDept DropdownList (renders as HTML select element) from the Dept table
Pulls all fields from the App record from DB as matched by id into a DataSet
Populates options in the ddlGroup DropdownList (another select) from the Group table, matching the DeptID pulled from the App dataset
Populates the data for all form fields from the App dataset
Important to Note: When you click Save, the page is posted back to the server and field data dumped into the database. If the save operation is successful, the browser is instructed to redirect to the current page's URL using Response.Redirect(Request.Url.ToString), resulting in a "clean load" (non-postback load) of the page.
Expected Behavior:
After the page has been successfully saved, hitting F5 or clicking refresh should result in another clean load (non-postback) of the page, and all fields should be populated just like a direct URL hit on the page.
Actual Behavior:
After the page has been successfully saved, hitting F5 or clicking refresh reloads the page as a non-postback (verified in VS debug), but the ddlGroup select element renders the "default" / first item ("Select One") instead of the item marked selected="selected" in the DOM.
I have stepped through every single line of VB code in debug — and when the server sends the page back after this "post-save" and supposedly "clean" load, the ddlGroup value is correct in code all the way out the door. Only in the browser, and only Firefox specifically, is the displayed value set to the wrong item, even though it's right in the DOM. Refreshing again doesn't help at all. When I try to save again, the RequiredField validator for ddlGroup complains that the field isn't valid, even though, again, it's supposedly right in DOM.
This seems to me to be a very bad Firefox bug.
Thoughts?
So, this isn't really what I consider a proper "solution," but rather more of a stable work-around.
Adding autocomplete="off" to the offending select (DropDownList in the aspx markup) magically prevents Firefox from messing up the displayed element within the select, thus always showing the correct one that is marked selected="selected".
I've gone ahead and added it (and will add it) to all of my DropDownLists / selects from now on... thanks Firefox.

Keeping cached browser data inside ASP update panel textboxes/dropdowns for browser back click

I'm new in VB.net/asp and am running a VB web application in a visual database program called IronSpeed designer. I'm primarily using IronSpeed in this case for its login/role security features.
I have a basic two page setup for this app. The user logs in then is taken to AccountEntry.aspx, they enter data into textboxes and select some dropdown values that are linked to a sql database, then they click "submit" to move to Results.aspx. On Results.aspx, the user can change data and then generate several types of reports (PDF, Excel, etc).
I'm used to setting up ASP controls inside ASPContent areas, and in these areas if a user performs a browser back click the previously entered data will still be on the page for potential user modification.
However in this web app, IronSpeed is setting up the page and asp controls inside an asp update panel. It appears inside an asp update panel, cached values can't be seen on a browser back click. In this case, it's important that the orginally entered values still be there for the user experience if the user advances to Results.aspx then clicks browser back to modify a value on AccountEntry.aspx.
If I have to I'll setup Session Variables and disable browser clicking, but that is last resort. Is there any way to save cached data inside an asp update panel and have it there for a browser back click?
The best you can do is creating a class, filling it with your form data and
store it in browser session.
Public Class Navigation
Property Data1 as string
Property Data2 as string
Property ComboValue as string
Property WhateverDesiredValue as string
End Class
Save the user data into the class and keep it in Session.
Dim myNavitadionClass as new PreviousNavigation With { .Data1="" 'Assign values }
Session("PreviousNavigation") = myNavitadionClass
'Submit the form.
Then when you came again to the form you check the page_load event.
If Not Session("PreviousNavigation") is Nothing Then
Dim myClass as Navigation = Ctype(Session("PreviousNavigation"),Navigation)
End If
And then you can fill the form exactly as it was.

SSRS Report Hyperlink Loses Functionality in .net Application

I have an SSRS report that employs RowGroups to group data. One of the fields used in the group is a field that stores a URL as text. I've set a Go To URL action on a textbox which enables it to act as a hyperlink that opens up the URL stored as text in a field (i.e. =Fields!URL.value).
The textbox works fine in BIDS and in Report Manager, but when the report is accessed through our custom .asp Reporting Application, the textbox loses this link functionality. It just becomes text. When the mouse is hovered over the textbox, the cursor does not change. I've created another textbox on the report outside the RowGrouping and configured it the same way, and it works fine in the Report Manager and on the Report Application.
Is there any particular configuration that could be restricting a Go to Action property when in a RowGroup on a Reporting Application? Could this be an issue with the report, or an issue on the Reporting App end?
If you are using the ReportExecutionService check to make sure Javascript is true in the device info parameter?
<DeviceInfo>
<JavaScript>True</JavaScript>
</DeviceInfo>
But you said it worked if it was in another part of the report?
link to <DeviceInfo> Details
Never really found an answer to this problem, but a work around I used was placing a textbox to the right of the grouped textbox, where the link seems to work fine.

Retrieving image from sql database by its path

I have a database where i have the physical path where image of a person is stored .
now i want a code by which I can display the image of that person in a aspx window.
as I am new to asp.net & C#
can somebody provide me the full code of aspx page and the C# code behind it?
Here's a good example on how to connect to a database and display the data in ASP.NET: How to: Bind to Data in a Templated Control on MSDN.
Also there a lots of great tutorials on the ASP.NET "official" site.
Update:
Alright, now we got something to work with. Do you know if your HttpHandler is throwing any exceptions? Place a breakpoint in the HttpHandler code and hit F5 (Visual Studio) to launch the site in debug bug mode. Maybe you're not passing an image ID to the handler? Try and hardcode an ID in the .aspx for an image you know that exists in the database.
See if you can update your question and format the code: Just select the code sample and click the "code" button in the editor. It will indent the text and apply nice formatting, making it easier to read.
Also include your .aspx page so we can see what's going on there.

Resources