Showing posts with label window. Show all posts
Showing posts with label window. Show all posts

Wednesday, March 28, 2012

UpdatePanel - DataGrid - Client Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

hello.

an easy way to do this is to add a dummy button and then perform a click programatically on that button. this should be enough to force the postback. you can also take a look at the postbackaction or event call the _dopostback method directly.


That Works fine
Thanks Madeira  
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

That Works fine
Thanks Luis Abreu
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

Does this only work from within the update panel?

I'm trying it from outside the panel and it is refreshing the whole page.

UpdatePanel - Javascript Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

I think this is possible. I've got the initial idea fromhere.
So put a hidden div into the UpdatePanel, for example:

<div style="display:none;">
<asp:Button id="btnHidden" runat="server" OnClick="btnHidden_Click" UseSubmitBehavior="false" /></div>

Then "trigger" this button in your popup window from javascript:

var refreshHelper = window.opener.document.getElementById( "btnHidden" );
refreshHelper.click( );

It works for me, but maybe there is smarter solutions than this.

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.


Luis Abreu:

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.

Luis (or anyone else), can you provide an example of using postback action? I'm trying to accomplish something very similar and the dummy button approach doesn't appeal to me.

-Lee


hello.

well, the dopostback action (or, if you want to use javascript, the __doPostBack method) will only work out correctly if there's a control placed inside the form which will be considered responsible for the postback.


Hi Luis,

I do have a a DropDownList that is inside the form so I that would work. I suppose I could just call the __doPostPack method, but I was hoping there would be something that was specific to ATLAS that would force the UpdatePanel to refresh.


hello again,

well, i guess that the answer is no, there isn't. and the reason is simple too: the update panel is just a delimiter that identifies a region which will be refreshed dinamically. all the partial postbacks are controlled by the pagerequestmanager object which uses the updatepanels defined on the page (normally divs or spans) to decide if it should perform a partial or a complete postback.


Ok, so what would you say would be the best way to accomplish this? It sounds as though the options are limited to the dummy button approach or explicitly calling __doPostBack.

hello again.

yep, that's it. i think that currently, there's no other option to perform that kind of operation.

Monday, March 26, 2012

UpdatePanel & Opening a new window when returning from code-behind

Hi there,

Here's the OnClick event code for a button inside an UpdatePanel:

protected void btnReport_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "viewRepo", "<script>window.open('RepoViewer.aspx','viewReport')</script>");
}

As you can see, after returning from code-behind I want to open a new browser window with a given web form. Well, this works correctly without an UpdatePanel, or when EnablePartialRendering is set to false.

If EnablePartialRendering is set to true, a new window does not open.

Any workarounds?

-Benton

I'm having the same issue.

Rob


Hi Benton,

I'd the same problem, but I solve it, use've just to remove the tag scrip from your code (belive, it works!!!)

I used before this:

Sub wOpen(ByVal fWindow As String, ByVal fNameWin As String, ByVal fWidth As Integer, ByVal fHeight As Integer, ByVal fMenu As Boolean, ByVal fResizable As Boolean, ByVal fScroll As Boolean)
Dim strJ As String
strJ = "<script language='text/javascript'>"
strJ &= "window.open('" & fWindow & "', '" & fNameWin & "', "
strJ &= "'width=" & fWidth & ", height=" & fHeight & ", menubar="
If fMenu = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", resizable="
If fResizable = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", scrollbars="
If fScroll = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= "')<"
strJ &= "/script>"
'Page.RegisterClientScriptBlock("wOpen", strJ)
'Me.ClientScript.RegisterStartupScript(Me.Page.GetType(), "wOpen", strJ, True)
Me.ClientScript.RegisterStartupScript(Me.GetType(), "wOpen", strJ, True)
End Sub

And now I'm using:
Sub xOpen(ByVal fWindow As String, ByVal fNameWin As String, ByVal fWidth As Integer, ByVal fHeight As Integer, ByVal fMenu As Boolean, ByVal fResizable As Boolean, ByVal fScroll As Boolean)
Dim strJ As String
strJ = "window.open('" & fWindow & "', '" & fNameWin & "', "
strJ &= "'width=" & fWidth & ", height=" & fHeight & ", menubar="
If fMenu = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", resizable="
If fResizable = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", scrollbars="
If fScroll = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= "')"
Me.ClientScript.RegisterStartupScript(Me.GetType(), "xOpen", strJ, True)
End Sub

Note that I just remove the javascript tag, and it works very well.

jb.alessandro:

Hi Benton,

I'd the same problem, but I solve it, use've just to remove the tag scrip from your code (belive, it works!!!)


Note that I just remove the javascript tag, and it works very well.

Hi JB,

I am having the same problem. I hope there is a way to fix it with my case. Below is my script. Thanks

Response.Write(

"<script>window.open('../MailCenter/mailMain.aspx?tomemid=" +Convert.ToInt32(ViewState["MemID"]) +"','_blank');</script>");

How is it possible to remove the tags in this case? I tried but it didn't work.

blumonde

UpdatePanel & LinkButton

Hello

I have modal dialog (window.showModalDialog) with UpdatePanel & Link button in it.

Dialog dows not allow postback.

When I use Button control i can update UpdatePanel without probkecms.

When I use LinkButton i have postback and cant get async results (new window opens with error).

Haw can i use LinkButton to update content without this problem.

Thanks

Are you using AsyncPostBackTriggers?

basic outline:

<UpdatePanel id="up1" runat="server"> <ContentTemplate> </ContentTemplate> <Triggers><!-- Place triggers here so it knows which controls trigger async postback--> <AsyncPostBackTrigger ControlID="MyControlID" /> </Triggers></UpdatePanel>

I register linkButton withRegisterAsyncPostBackControlMethod.

All works ok in common window. But in modal dialogs it invoke __doPostaBack, whitch is not allowad in dialogs.

May be It because Button have click event, but LinkButton is <a> and has href?


Could you share some code that reproduces the problem?


UpdatePanel updatePanel =newUpdatePanel();

updatePanel.UpdateMode =

UpdatePanelUpdateMode.Conditional;this.Controls.Add(updatePanel);LinkButton m_SeachLinkButton = new LinkButton ();

m_SeachLinkButton.Click += new EventHandler(FormUpdater_Event)

cell.Controls.Add(m_SeachLinkButton);

this.RegisterAsyncPostBackControl(m_SeachLinkButton.LinkButton);


This code isn't enough to reproduce the problem. It raises a lot of questions... I assume this snippet is running in a method of your page (hence "this.Controls.Add(updatePanel)". But you also do "this.RegisterAsyncPostBackControl()", yet that method is on ScriptManager. You also add the LinkButton to something called "cell", but you don't show any code for that.

I need to be able to run your code so I can see what's happening... could you please provide the entire source for a page that shows this bug?

UpdatePanel (and other Ajax) not working inside of a frame

Hi,

I'm working on a project that uses a frame for the navigation and then a larger window for the actual content. Most of the site is built with classic ASP - which I know very little of - and we're working towards converting it piece by piece to .NET. I built up a page with several UpdatePanels and at least one UpdateProgress controls on it. Everything works absolutely perfectly until I try to bring it into the frameset used by this site. I thought maybe it was just being inside a frame that it didn't like so I made a simple prototype inside a frame from scratch and ran it outside of our site frame (the top navigation frame was just pointed to google.com and the content frame was what I was testing) and that worked just fine.

I guess the end result of all that is that there's something somewhere in the old ASP section of the site preventing me from using any Ajax on the site. Being so unfamiliar with ASP, I'm not even really sure where to begin troubleshooting something like that.

Any ideas or suggestions would be greatly appreciated. Thanks!

one thing to note is that using frames is becoming an old obsolete practise and if you are moving to .net I would recomend switching to masterpages to handle navigation and such


I believe that's in the plans at some point. I inherited this site and the frames with it so for the moment, there's nothing I can do about it, unfortunately. I definitely would prefer to go the master page route.

UpdatePanel -> window.close

Good morning @dotnet.itags.org. all

I am working on a ModalDialog window, there i have UpdatePanel over the whole modalDialog, Inside of it several atlas/ajax components.
Inside on top i have a Button to save the Datasheet/ Data fields. On other modals before i did it like so:

btnSave_Onlick -> save data to SQL and after it (last command) Response.Write ....window.close / PageStartupScript...window.close...
It worked fine in the past, but now the button is inside of the updatepanel and it throws out a Error with the response.write method,
and if i use StartupScript it just dont close the window. Is there any method to do this events inside of an updatePanel event?

Thanks for reponses
Marc

Specifially - Response.Write commands kill the whole microsoft.ajax enviroment - specifically with the new BETA. (I learned the hard way unknowningly)...

The alterantive is to just use a label or textarea (html) and assign values to after doing whatever you need to display after whatever processing. Little confused though are you talking window close as in IFRAME or modalpopup.show() hide()? Your post seems to indicate you are using an iframe and not a modal...

None the less if modal - then wrap the form or whatever you present in the modal in a panel and on successful submit make it not visible and assign a lable or generichtmlcontrol and display whatever message you want in it with a close button ...


hello.

if you're trying to insert javascript statements from a partial postback then use the new registerXXX static methods of the scriptmanager class.


Ok Thanks Luis i will remind it for further things :D
After all, for this i just brought my button outside of the panel...wasnt that big problem.

Saturday, March 24, 2012

UpdatePanel and Exception

When throw out an Expcetion inside UpdatePanel, the error message will be display in a message box window.
How to customize the style of message in this message box? For instance, when I use \n, \r, <br> to try to seperat the message into mutiple line, it doesn't work. How to implelent it?

If throw out an exception not inside UpdatePanel, the error message will display in the page directly.
So anyway to decide the way of dispalying errormessage?

You need to specify an ErrorTemplate in your ScriptManager. There is also a server event handler that you can hook into.

See documentation here:
http://atlas.asp.net/docs/Server/Microsoft.Web.UI/ScriptManager/P_ErrorTemplate.aspx

HTH,

Perry