This is a migrated thread and some comments may be shown as answers.

Get the screen resolution in code behind

3 Answers 303 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 09 Feb 2009, 02:33 PM
Hello
Does it have a way to get the screen resolution in code behind
because in my code behind I have code like that
 Private Sub RadGrid_BanqueCV_DataBound(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadGrid_BanqueCV.DataBound  
        Dim grid As RadGrid = TryCast(sender, RadGrid)  
        Dim gridItems As Integer = grid.MasterTableView.Items.Count  
        If gridItems < 5 Then 
            grid.Height = 450  
        Else 
            grid.Height = 450 + (gridItems * 20)  
        End If 
        If grid.Height.Value > 650 Then 
            grid.Height = 650  
        End If 
    End Sub 
 But instead to have fixed values I would like to have screen resolution value to set the height.
Thanks!

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 09 Feb 2009, 02:54 PM
Hello Myriam,

Please refer to this forum post for details on the matter.

Greetings,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Myriam
Top achievements
Rank 1
answered on 09 Feb 2009, 04:34 PM
Hello!
Thanks for your quick reply!
I'm trying to add a javascript sub to the radgrid...but I can't raise the event
I tried databound and itemdatabound but after a while I saw that I can't raise these events as there are server side sub, so I tried also OnLoad event...I don't know what I am doing wrong...
Here is what I tried
RadGrid_BanqueCV.Attributes.Add("OnLoad""javascript:SetDimension();"

here is my aspx code
 <script type="text/javascript">  
 
function SetDimension()  
{  
document.getElementById(RadGrid_BanqueCV).height = screen.height-100;  
alert("In Bar Method");  
}  
 
</script> 

I also tried to put it directly to the .aspx form to the radgrid like that

 

 

 OnLoad="javascript:SetDimension();" 
But I get the error
'javascript' n'est pas un membre de 'ASP.fen_entreprise_aspx'.
Which mean that javascript is not a member of my page....
What am I doing wrong?
Thanks again

0
Pavlina
Telerik team
answered on 12 Feb 2009, 07:58 AM
Hi Myriam,

When you set width and height styles with Javascript, you must also include the measure unit, e.g:

grid.style.height = screen.height-100 +"px";     

JS:
<script type="text/javascript">     
    
function SetDimension()     
{     
document.getElementById(RadGrid_BanqueCV).style.height = screen.height-100 +"px";     
alert("In Bar Method");     
}     
    
</script>   

Give try on the code snippet and see if it works for you.
You can see the following link as well.

Regards,
Pavlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Myriam
Top achievements
Rank 1
Answers by
Paul
Telerik team
Myriam
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or