Sirdots
asked on
How to control width and height of an aspx page from code behind
I have a page that uses they hyperlink control. I want to be able to navigate to a popup window
with specific dimensions and pass a parameter at the same time to the AttorneyContact page.
I have my html like this :
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/AttorneyCon tact.aspx" Target="blank" runat="server" >Attorney contact information |</asp:HyperLink>
<Fields>
<asp:BoundField DataField="CaseNumber" HeaderText="CaseNumber" ReadOnly="True"
SortExpression="CaseNumber " />
</Fields>
Because I need to use the value of a detailsview as my parameter, I had to pass this from the onload event of my page.
this.HyperLink1.NavigateUr l = "AttorneyContact.aspx?" + this.DetailsView1.Rows[0]. Cells[1].T ext;
How can i set the width and height of this page and turn off unnecessary toolbar from the line above within my code behind.
with specific dimensions and pass a parameter at the same time to the AttorneyContact page.
I have my html like this :
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/AttorneyCon
<Fields>
<asp:BoundField DataField="CaseNumber" HeaderText="CaseNumber" ReadOnly="True"
SortExpression="CaseNumber
</Fields>
Because I need to use the value of a detailsview as my parameter, I had to pass this from the onload event of my page.
this.HyperLink1.NavigateUr
How can i set the width and height of this page and turn off unnecessary toolbar from the line above within my code behind.
ASKER
how do i now apply your code above to this line??
this.HyperLink1.NavigateUr l = "AttorneyContact.aspx?" + this.DetailsView1.Rows[0]. Cells[1].T ext;
this.HyperLink1.NavigateUr
You dont.
You apply the code to the attorneycontact.aspx page - to make it resize itself when loaded.
So in the page_load event of attorneycontact.aspx put the code I posted above.
You apply the code to the attorneycontact.aspx page - to make it resize itself when loaded.
So in the page_load event of attorneycontact.aspx put the code I posted above.
Unfortunately ths solution CB posted isnt really applicable as it only talks about calling javascript on the SAME page that contains the hyperlink/linkbutton.
You need to cause some javascript to run AFTER the attorneycontact.aspx page loads to resize it, you cant do it before the page loads because it doesnt exists at that time.
You need to cause some javascript to run AFTER the attorneycontact.aspx page loads to resize it, you cant do it before the page loads because it doesnt exists at that time.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
One will expect that the hyperlink below will work since i have the
navigateurl part in the code behind of my page_load.
This does not work.
singlerecord.aspx
------------------------
<div id="navcontainer">
<asp:HyperLink ID="HyperLink1" runat="server" >Attorney contact information |</asp:HyperLink>
</div>
singlerecord.aspx code behind
-------------------------- -----
if i do this below then it works with the javascript but the toolbar is still there
<div id="navcontainer">
<asp:HyperLink ID="HyperLink1" NavigateUrl="~AttorneyCont act.aspx" Target=_blank runat="server" >Attorney contact information |</asp:HyperLink>
</div>
singlerecord.aspx
-------------------
protected void Page_Load(object sender, EventArgs e)
{
this.HyperLink1.NavigateUr l = "javascript:popup(600,700, 'AttorneyC ontact.asp x?" + this.DetailsView1.Rows[0]. Cells[1].T ext + "');";
}
The sizing does not work at all.
Attorneycontact.aspx -- html section
---------------------
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript>
function popup(width, height, url)
{
var win = window.open(url,'popup', 'toolbar=0,scrollbars=0,lo cation=0,s tatusbar=0 ,menubar=0 ,resizable =0,width=' + width + ',height=' + height);
}
</script>
</head>
navigateurl part in the code behind of my page_load.
This does not work.
singlerecord.aspx
------------------------
<div id="navcontainer">
<asp:HyperLink ID="HyperLink1" runat="server" >Attorney contact information |</asp:HyperLink>
</div>
singlerecord.aspx code behind
--------------------------
if i do this below then it works with the javascript but the toolbar is still there
<div id="navcontainer">
<asp:HyperLink ID="HyperLink1" NavigateUrl="~AttorneyCont
</div>
singlerecord.aspx
-------------------
protected void Page_Load(object sender, EventArgs e)
{
this.HyperLink1.NavigateUr
}
The sizing does not work at all.
Attorneycontact.aspx -- html section
---------------------
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript>
function popup(width, height, url)
{
var win = window.open(url,'popup', 'toolbar=0,scrollbars=0,lo
}
</script>
</head>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Something like:
Page.ClientScript.Register
function setWindowSize(){
//whatever cross browser javascript you like to change window size.
window.height=100;
window.width=100;
}
", true);