ASP.Net 4.0 image select and change source - asp.net

If I have a set of image (buttons) or even just plane images, 5 in a row, and I want to achieve the following, what would be the easiest way, I can't realy find a good solutions to this:
On clicking either of the images, it needs to get a new src, but others need to be restored to the original state.
A Asp:Label needs to be set on clicking, based on the image clicked
On doing a PostBack, I need to know which one is selected
Asside from this, it's asp.net 4.0, so single quotes are giving me javascript pain.

On clicking either of the images, it needs to get a new src, but others need to be restored to the original state.
First of all you have to create a function in which you will set all 5 images to the original state.
Then be sure to give same class name to each image element.
After that crate a function which will fire according to class name like
$(".classname").click(function(){
//first call the function which will set all 5 images to original state.
//then change the source of the current image. onwhich user has clicked as below:
$(this).attr("src","new source");
// here you can store the id of current image in a variable to keep the record which images have been clicked
});
A Asp:Label needs to be set on clicking, based on the image clicked
you can easily set the Asp:Label in above function. If you are familiar with javascript code. Its too simple to set.
On doing a PostBack, I need to know which one is selected
After creating the first function your rest of two steps get completed them selves.
in above function you have saved the IDs of images on which a user has clicked in a variable.
on doing postback you can easily save the varibale's data in hiddenfield or assign it to static varibale or what ever the way you like.
at last you can access it in code behind.
If i have to do this thing. i'll follow the above process. Its far easy and fast process. Everything can be done at client side.
what you think?

Related

I need to display a pop up table on clicking a button in vb.net. How do i do this without the gridviews just on plain button click?

I need a table to pop up or flash on the users screen when a button is clicked
It is a reference table, users can go back and check the codes while filling a form. This is to be done vb.net. Please help me i need the simplest solution possible
in my opinion:
1) If you don't insist on formatting and you would like to only display table data, you can simply write the data into string, which you will display in a MsgBox dialog. You'll probably will have to take care about partial string lenghts in columns (trim, or complete with spaces to a specific length) and then it will look OK. Bellow is an example of such data (only a test dialog) without any trimming/completeng:
2) For a serious table, you'd have to either use datagrdiveiw (or such) in a separate form, or draw your table using GDI, which would be a rather complicated and eccentric method.

DataRepeater becomes empty

I'm using a DataRepeater control in my VB.Net application so I can make a custom-made list control.
I know it's main functionality is to work with dataSets and stuff, but I don't actually want to transfer my stuff into a database because in the program's context it doesn't actually make any sense.
So my goal here is to use a dataRepeater to list the contents of a mail inbox.
Everything works just fine until I scroll down the control. As I scroll down/up to see every item (in this case, every listed e-mail), the contents disappear and all I can see is a bunch of lines with the controls' default values assigned - like "Label1" and so on.
This is how I'm filling the dataRepeater (abreviated):
For each m as Message in mail.Inbox
dr.Addnew()
With dr.CurrentItem
.Controls("lblFrom") = m.From
.Controls("lblSubject") = m.Subject
End With
Next
As I said, the dataRepeater shows up perfect until I scroll it up/down, and when I do it all the data just disappears remaining only the items with the controls' default (design-time) values.
Am I missing something here? Or is it just not possible to work with a dataRepeater to fulfil my idea?
UPDATE:
Got my answer right here!
The repeater isn't going to hold the values on its own. You dont have to use a datasource, but you have to use something. Here is an example where they used a simple integer array: VB.NET Repeater Simple Data Binding Without Datasource

Use Page Items in a Button Link in Apex Express

i have a little problem. I'm using Oracle Applicarion Express and i'm trying to use some page items in a Link created for a button. I created the Button as region button, and selected in the region" Action when button clicked" "Redirect to URL". In this URL i want to use two pageitems. I tried already to use them mit ":PAGE_ITEM" or "&PAGE_ITEM." but non way works. Can someone help me please?
What does the resulting hyperlink look like? The chance is great that it looks like
f?p=<app_id>:10:<session id>::::P10_ITEM1,P10_ITEM2:,
This is because when using the substitution syntax like &PAGE_ITEM. will put the session state of the referenced item in the string. Since the button is rendered during the loading of the page it will use the session state of the item at that time.
When you then fill in a value for PAGE_ITEM, this will not change the session state of that item - and even if it did it would not matter since the button was already rendered.
If this is the case then you'd better have the button submit the page, and define an on submit before validations/computations branch to act on that button. In the branch you can then safely use the session state of the required items.

Flex/QNX scrolling gallery

I was hoping someone could give me some guidance on building an image gallery which loads images dynamically for a PlayBook application.I've uploaded a quick mockup of what I am trying to achieve, I want to dynamically load images into a QNX TileList or Flex equivalent and as the user scrolls through the list I want to call another 'page' of images dynamically. I have already produced an example which uses a custom cell renderer to dynamically load images but I am having problems when I attempt to identify when the user has reached the end of the list.
I have tried using the lastVisibleItem property of the list while the user is scrolling to identify if the last item visible in the list is also last in the DataProvider (so I know when I need to call for more images) but when I add images to the DataProvider it takes me back to the start of the list, can anyone tell me the reason for this?
Any advice on a different approach or how to modify the TileList would be greatly appreciated.
The scrollPosition automatically gets reset to 0 when you update the dataProvider. I've done workarounds that store the current scrollPosition before updating the dataProvider and then re-set it after the update to the dataProvider has completed. Let me know if you need some code sample and I'll see if I can dig something up.
Another option would be to use dataPaging. Here is a good example of how to do that:
http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/

Is it possible to catch a comboBoxes value before change with a change event

I am displaying a combo box in something of a WYSIWYG preview. I want the user to be able to click on the combo box and see the options inside, but I don't want them to be able to change the value. I tried using preventDefault() on the change event but it doesn't work. I don't want to disable it because I do want the user to be able to "look inside" the dropdown.
So I'm trying to block the change, but can't. My next resort is to change the selected index back to what it was before the change, Is there any way to do this within the scope of a ListEvent.CHANGE event listener?
Current Workaround is to basically re-assign the controls selected item the same way I am defining the selected item when I originally build it (a default selection). So a user sees their change then it immediately changes back to the default selection.
Are you sure that a combobox is what you want? could you do the same thing with a list component that is not selectable?
update:
If you must use a combobox and you dont want the lag from listening for the event and resetting the control, I see two possible options. You could subclass the control and make your own. When you do, hijack any methods that set the value besides the initial selection.
Or, you could try something like this: http://wmcai.blog.163.com/blog/static/4802420088945053961/. The site seems like it is in another language but the code is still there. It will allow you to make your options disabled, so the user cannot choose one of the other options.
HTH

Resources