Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Setting and Retrieving Cookies

Author  Topic 

ninel
Posting Yak Master

141 Posts

Posted - 2006-04-13 : 16:00:23
I have page1.aspx. On this page I have a link to a pdf file and a checkbox that is disabled. When user clicks on link they get redirected to page2.aspx, which is actually a 2nd window that pops up. On this page I update a table specifying that the link was clicked and using the following code display the pdf:


Response.ContentType = "Application/pdf"
Response.Redirect("05. Incentive Policy.pdf")


I need to enable the checkbox on page1.aspx after the link for the pdf has been clicked.

How can I do this? I'm trying to set a cookie on page1 and then reset it with a different value on page2, and then somehow read it from page1, but this isn't working.

Thanks,
Ninel

jubinjose
Starting Member

20 Posts

Posted - 2006-04-14 : 05:08:02
what about including a javascript for the link of page1. The script will
1) open page2 as popup
2) call page1 passing some param to denore that link was clicked. In page1 detect the param and check the checkbox
Go to Top of Page

ninel
Posting Yak Master

141 Posts

Posted - 2006-04-14 : 10:38:51
That would be great. Do you have any code you help me with?

This is what I have so far:

Page1.aspx
HTML:
<asp:hyperlink id="hlnkTest" runat="server" Font-Names="Tahoma" Font-Size="x-Small" ForeColor="BLUE" Visible="true"></asp:hyperlink>
<asp:checkbox id="chkRead" runat="server" OnCheckedChanged="chkRead_checked" AutoPostBack="true" Font-Size="x-Small" Font-Names="Tahoma" Text="I have read the new/updated policies"></asp:checkbox>

ASPX:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
hlnkTest.Visible = True
hlnkTest.Target = "_blank"
hlnkTest.Text = "TEST"
hlnkTest.Attributes.Add("onclick", "enableCheckBox()")
hlnkTest.NavigateUrl = "Page2.aspx"
chkRead.Enabled = False

Dim str As String
str = "<script language='javascript'>"
str = str & "function enableCheckBox() {document.getElementById('chkRead').disabled = false;}"
str = str & "</script>"
Response.Write(str)
End If
End Sub


I'm not getting any errors, but it's also not enabling the checkbox.
What am I doing wrong?

Thanks,
Ninel
Go to Top of Page

jubinjose
Starting Member

20 Posts

Posted - 2006-04-14 : 12:04:08
Page1 - html
<script language="JavaScript"><!--
function openWindow(){
document.myform.testcheck.checked=true;
window.open('page2.html','messageWindow1','scrollbars=yes,width=175,height=300');
}
//--></script>
<form name="myform" >
<input type="checkbox" name="testcheck" value="1">Test<br>
<a href='javascript:openWindow()'>hello</a>
</form>

Page2 - html
<title>
page2
</title>

Now open Page1 in IE and click on the link. Is this not what you are trying to do?
If you want page1 also to be refreshed add that line also to the javascript function
Go to Top of Page

ninel
Posting Yak Master

141 Posts

Posted - 2006-04-14 : 12:56:26
I don't think it's that simple.

When the link is clicked on page1 I need to display the pdf in page2. The only way I got the pdf to open properly was to use .NavigateUrl and at the same time enable the disabled checkbox on Page1 only when the link is clicked.
Go to Top of Page

jubinjose
Starting Member

20 Posts

Posted - 2006-04-14 : 13:11:55
yes and in this case if u replace page2.html call with a call to your page2.aspx what is the issue?
Go to Top of Page
   

- Advertisement -