Showing posts with label surrounding. Show all posts
Showing posts with label surrounding. Show all posts

Monday, March 26, 2012

updating panelsize within scriptmanager

I need some help.

I have a masterpage with a scriptmanager surrounding my contentplaceholder. When I activate my defaultpage using the masterpage, the page_load reads in javascriptcode (RegisterStartupScript). This code runs at window::load(). The effect is that the size of a panel-component inside the contentplaceholder is set depending on the size of the window.

That works fine.

But when I read in the default-page again (using a button) the onload-event is not activated. That is the one of the good things in ATLAS, but it gives me a little problem: The size of the panel-control gets at new size according to the amount of data within the panel.

What do I have to do, when I want the size of panel to stay unchanged ?

I hope you understand my problem even thought my english is not the best.

hi sixtus,

I think i encountered the same problem !
the solution I found is :


<%@. Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="testGbControls._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function resizeMe()
{
document.getElementById('panel').style.height = 200;
document.getElementById('panel').style.width = 200;
}

function PageRequestManagerPropertyChanged(sender, args)
{
if (args.get_propertyName() == "inPostBack")
{
if (!$object("_PageRequestManager").get_inPostBack())
resizeMe();
}
}
function pageLoad()
{
$object("_PageRequestManager").propertyChanged.add(PageRequestManagerPropertyChanged);
}
</script>
<script runat="server"
protected void btn_Click(object sender, EventArgs e)
{
this.content.Text += "ligne" + "<br> ";
}
</script>
</head>
<body onload="resizeMe()">
<form id="form1" runat="server">
<div id="panel" style="background-color:Red;overflow:scroll;width:100;height:100;">
<atlas:ScriptManager runat="server" ID="mngr" EnablePartialRendering="true" EnableScriptComponents=true >
</atlas:ScriptManager>
<atlas:UpdatePanel runat="server" ID="updpnl">
<ContentTemplate>
<asp:button ID=btn runat=server OnClick="btn_Click" />
<asp:label id=content runat=server Text="ligne"></asp:label>
</ContentTemplate>
</atlas:UpdatePanel>
</div>
</form>
</body>
</html>

the div "panel" is resize on each atlas postback
I hope this help you
Gildas

Unfortunately it doesn't solve my problem, because I am using Masterpages. Or I haven't totally understood the solution.

You can se my problem onhttp://localhost/scripts/ASP.NET/Oresund2/Vis/opslag.aspx?id=1

When the page is read the lightbrown panel has the right dimensions. When I click the Tekst-button in the panel, the panel keeps its dimensions as it should. Because the page is re-read I figure.

But if I choose Fredensborg in the Treeview (no postback I think) the dimensions in the panel is changed.

How do I solve that problem when then treeview and the panel isn't placed in the masterpage but in the aspx-file?


Sorry - the link was wrong. Here is the correct one:

https://temp.eg-gym.dk/scripts/asp.net/Oresund/vis/opslag.aspx?id=1


hi,
Is your lightbrown panel a <div> sizing by a javascript on load ?
can you post the code of your panel please

It looks like you got some good stuff going already on your UpdatePanel. My example might still help from the standpoint that I assure, using my method there, that the host control COULD always stay the same size (although it might not be obvious in the presentation because I don't enforce it).


I don't use a div but <asp:panel...>.

The code in page_load is:

If (Not ClientScript.IsClientScriptBlockRegistered("SetPanelScript"))Then

Dim sbScriptAsNew System.Text.StringBuilder

sbScript.Append("<script language=JavaScript>" & vbCrLf)

sbScript.Append("function opdater()" & vbCrLf)

sbScript.Append("{" & vbCrLf)

sbScript.Append(" var windowHeight = -1;" & vbCrLf)

sbScript.Append(" var windowWidth = -1;" & vbCrLf)

sbScript.Append(" if ( window.innerWidth ) {" & vbCrLf)

sbScript.Append(" windowWidth = window.innerWidth;" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append(" else if ( (document.documentElement) && (document.documentElement.clientWidth) ) {" & vbCrLf)

sbScript.Append(" windowWidth = document.documentElement.clientWidth;" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append(" else if ( document.body.clientWidth ) {" & vbCrLf)

sbScript.Append(" windowWidth = document.body.clientWidth;" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append(" if ( windowWidth > 335 ) {" & vbCrLf)

sbScript.Append(" document.getElementById('" +Panel1.ClientID +"').style.width = windowWidth - 335;" & vbCrLf)

sbScript.Append(" }" & vbCrLf)

sbScript.Append(" if ( window.innerHeight ) {" & vbCrLf)

sbScript.Append(" windowHeight = window.innerHeight;" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append(" else if ( (document.documentElement) && (document.documentElement.clientHeight) ) {" & vbCrLf)

sbScript.Append(" windowHeight = document.documentElement.clientHeight;" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append(" else if ( document.body.clientHeight ) {" & vbCrLf)

sbScript.Append(" windowHeight = document.body.clientHeight;" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append(" if ( windowHeight > 110 ) {" & vbCrLf)

sbScript.Append(" document.getElementById('" +Panel1.ClientID +"').style.height = windowHeight - 120;" & vbCrLf)

sbScript.Append(" }" & vbCrLf)

sbScript.Append("}" & vbCrLf)

sbScript.Append("window.onload=opdater" & vbCrLf)

sbScript.Append("</script>" & vbCrLf & vbCrLf)

ClientScript.RegisterClientScriptBlock(GetType(String),"SetPanelScript", sbScript.ToString())

EndIf

InTreeView1_SelectedNodeChanged I have got the advice to write the following, but it doesn't work.

Dim scriptKeyAsString ="setPanelScript"

Dim sbScriptAsNew System.Text.StringBuilder()

sbScript.Append("<script language=JavaScript>" + ControlChars.Lf)

sbScript.Append("<!--" + ControlChars.Lf)

sbScript.Append("opdater2();" + ControlChars.Lf)

sbScript.Append("// -->" + ControlChars.Lf)

sbScript.Append("</script>" + ControlChars.Lf)

ClientScript.RegisterClientScriptBlock(GetType(String), scriptKey, sbScript.ToString())

The panel is resized correct when the whole page is reread, but the size is changing when I select a item in the treeview.

Saturday, March 24, 2012

Upload control in a Wizard in an Update Panel. How to add the trigger dynamically?

I have an update panel surrounding a Wizard control. One of the steps in that wizard is that the user can upload photos. So what I want to do is add a trigger to force a full postback on the upload step.

Is this at all possible? I'm having troubles obtaining the correct ControlID to add on the trigger...

ctafield:

I have an update panel surrounding a Wizard control. One of the steps in that wizard is that the user can upload photos. So what I want to do is add a trigger to force a full postback on the upload step.

Is this at all possible? I'm having troubles obtaining the correct ControlID to add on the trigger...

Hi.

FileUpload is not supported with ASP.NET AJAX .because that you cann't use it and you cann't find it with ControlID's!


Create a Button Control and set this as a PostBack trigger forupdatePanel. In the Button Click event save the file from File uploadcontrol.

anishdevasia:

Create a Button Control and set this as a PostBack trigger for updatePanel. In the Button Click event save the file from File upload control.

Thank you for the suggestion. I'll give it a go!