I have a Datalist that has a bunch of controls in it and one of the controls is an ImageButton that will come up if the DataSource field has a statusID =4. Otherwise I dont care. But if this StatusID is a 4 I show a certain image(which means that record has comments) and the user can click on that image and I want a Modal Popup Extender to popup and the fields be displayed. Now, for my modal popup I just have a table with a couple of rows inside a panel and it has 2 fields in it. The WeekID and the Comments for the Record which I have in Session.
I have tried multiple ways of getting my 2 values into these fields but I cannot seem to get this to work. I can even see the values being set but when the popup renders, it has nothing in the fields. I know it has something to do with the postback, or something like that, but I do not know how I can get this to work. I was able to add a button outside the DataList for testing and I was able to assign values to the controls in the Panel no problem but cannot do it with the DataList???....
I have been working on this for 2 days and Im going nuts, so if anyone has anything that would help me I would appreciate it. I am going to display my entire page markup so you can see everything in case I have forgotten to mention anything. The imgComments Image Button is where I would like to have the popup appear to show the comments and the weekid but I cannot seem to do it. I put a button outside of the DataList and was able to get it working with that but cannot get it to work with the image button????
PLEASE HELP!!!!!!
Also, if anyone has ANY questions related to this please just ask and I will get back ASAP!!! THANK YOU!!!!
I have the HiddenField1 here assigned as the TargetControlID as a dummy field, Then in the click of the btnPopup, I assign the values to the controls and then do the Show in the popup. This is when I was testing the popup modal to make sure it would work from outside the DataLIst, and it does.. .
Here is that code
Protected Sub btnPopup_Click(sender As Object, e As EventArgs) lblWeekID.Text = Session("WeekID") txtComments.Text = Session("Comments") PopupModal.Show() End Sub
My problem is that I do not want to use the button Popup button because it doesnt have anything to do with the app, I want to use the click of the image button. So while testing I wanted to make sure I can assign the Session vars in the imgComments click and I was able to do it, with the code below.
I probably should have put this piece of code in yesterday but here is the code for the image click event
And the Session vars have the correct values and if I check the .Text properties of the lblWeekID and txtComments when I step through the code, before I do the Show, the values are there. They just dont appear when the popup renders....
Protected Sub imgComments_Click(sender As Object, e As ImageClickEventArgs) Dim imgBtn As ImageButton = TryCast(sender, ImageButton) Dim hfComments As HiddenField = DirectCast(imgBtn.NamingContainer.FindControl("hfComments"), HiddenField) Dim lWeekID As Label = DirectCast(imgBtn.NamingContainer.FindControl("lblWeekNumber"), Label) Session("Comments") = hfComments.Value Session("WeekID") = lWeekID.Text PopupModal.Show() End Sub
PS -
Just an FYI, I am writing a timesheet application. The employee submits the timesheet (status is set to 2=Submitted) and the manager will either Approve(Status=3) or the manager Rejects(Status=4) the timesheet and that is where I am at right now. The employee trying to view the Managers rejected comments.
I just want to click on the image for the comments and show the comments for the employee to view. I also have to show a popup on the Supervisor page so the values can be written to the db but I started on the Employee side of things first. Employee will have to read the comments when the manager has inserted them for a specific week.
Please help me with this I can really use the assistance!!
Ramkisan Jagtap
You have written really good description of your problem. But still not clear where you can see the comments and weekid is it on popup?
You want to show the values on the popup, right?
Try this one.
Protected Sub imgComments_Click(sender As Object, e As ImageClickEventArgs) Dim imgBtn As ImageButton = TryCast(sender, ImageButton) Dim hfComments As HiddenField = DirectCast(imgBtn.NamingContainer.FindControl("hfComments"), HiddenField) Dim lWeekID As Label = DirectCast(imgBtn.NamingContainer.FindControl("lblWeekNumber"), Label) Session("Comments") = hfComments.Value Session("WeekID") = lWeekID.Text lblWeekID.Text = lWeekID.Text txtComments.Text = hfComments.Value PopupModal.Show() End Sub
I have tried this and it does not refresh the controls with the new vaues. I have attached a screenshot of the code that I have checked the values with and the Popup with no values...
I wish it was this easy but I have tried every variation of this. I believe that the problem has something to do with the Popup not posting back. Also, the problem has got to have something to do with the DataList because if I put a button on the form and in the Click event run the same code as in the pic, everything works fine. I believe, because Im relatively new to this, that the DataList is some type of container control and there is some type of heirarchy that is involved with it so Im not sure if that is messing me up or not. I do however find it weird that I cant click on a button in the DataList and have the values set but I can click on a button outside the datalist and everything run fine!!!!
Very depressing!!! Thanks for sticking with me though....
Hey sorry I didnt attach the pic that I had for you. Im gonna try your suggestion and will let you know...
jknj72
ASKER
I cant explain how happy I am because your suggestion worked on the first try. Also, Im pretty bummed out that I didnt try this already, but hey live and learn.
Thank you so much for your help. This was really holding me up and now I can move on....
Reason was your button was inside the update panel and Modal papup was outside. so when you were clicking the button it was doing postback only for the update panel. So it wasn't updating it.
I was quite sure that its gonna work if we put the modalpopup markup inside the updatepanel.
jknj72
ASKER
looking back at it, it sure make complete sense. I tend to overlook the obvious sometimes. I knew getting someone elses eyes on it would get it figured out. Thanks again!!
try to put following code on your link button click event.
protected void LinkButton1_Click(object sender, EventArgs e)
{
PopupModal.Show();
}