Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Should this code force a refresh of my asp.net page?

Reply
Thread Tools

Should this code force a refresh of my asp.net page?

 
 
COHENMARVIN@lycos.com
Guest
Posts: n/a
 
      05-02-2008
I have a button in my asp.net page (actually its in a user control
with a .ASCX suffix) called btnGetData. I'm trying to make it force a
refresh of my page. So what I did was make it call javascript.
Should the following work? (It doesn't seem to)

Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetData.Click
LoadGridView()
ForcePageRefresh()
End Sub


Sub ForcePageRefresh()
Dim popupScript As String
Dim instance As ClientScriptManager

instance = Page.ClientScript
popupScript = "<script language='JavaScript'>"
popupScript = popupScript & "
window.location.reload( true );"
popupScript = popupScript & "</script>"
instance.RegisterStartupScript(GetType(String), "PopupScript",
popupScript)
End Sub
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      05-02-2008
have no idea why on a postback, your code would render a command to request
the same page again to get the html, instead of returning the correct html
(sloppy coding I guess). you can just use Response.Redirect, no need for
javascript.

for either approach to work you shoudl decorate the url (add a dummay
parameter) to force a fresh copy rather than using a cached copy.

-- bruce (sqlwork.com)


"(E-Mail Removed)" wrote:

> I have a button in my asp.net page (actually its in a user control
> with a .ASCX suffix) called btnGetData. I'm trying to make it force a
> refresh of my page. So what I did was make it call javascript.
> Should the following work? (It doesn't seem to)
>
> Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnGetData.Click
> LoadGridView()
> ForcePageRefresh()
> End Sub
>
>
> Sub ForcePageRefresh()
> Dim popupScript As String
> Dim instance As ClientScriptManager
>
> instance = Page.ClientScript
> popupScript = "<script language='JavaScript'>"
> popupScript = popupScript & "
> window.location.reload( true );"
> popupScript = popupScript & "</script>"
> instance.RegisterStartupScript(GetType(String), "PopupScript",
> popupScript)
> End Sub
>

 
Reply With Quote
 
 
 
 
Stan
Guest
Posts: n/a
 
      05-02-2008
On 2 May, 15:38, (E-Mail Removed) wrote:
> I have a button in my asp.net page (actually its in a user control
> with a .ASCX suffix) called btnGetData. *I'm trying to make it force a
> refresh of my page. *So what I did was make it call javascript.
> Should the following work? *(It doesn't seem to)
>
> * Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnGetData.Click
> * * * * LoadGridView()
> * * * * ForcePageRefresh()
> * * End Sub
>
> * * Sub ForcePageRefresh()
> * * * * Dim popupScript As String
> * * * * Dim instance As ClientScriptManager
>
> * * * * instance = Page.ClientScript
> * * * * popupScript = "<script language='JavaScript'>"
> * * * * popupScript = popupScript & "
> window.location.reload( true );"
> * * * * popupScript = popupScript & "</script>"
> * * * * instance.RegisterStartupScript(GetType(String), "PopupScript",
> popupScript)
> * * End Sub


Hi

I am intrigued as to why you want to do this. Could it be that you are
trying to trigger execution of code on the host page when a User
Control button is clicked?
 
Reply With Quote
 
Niraj Ranka
Guest
Posts: n/a
 
      05-03-2008
Can you give the reason why u want to reload the same (loading) page again n
again ?

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a button in my asp.net page (actually its in a user control
> with a .ASCX suffix) called btnGetData. I'm trying to make it force a
> refresh of my page. So what I did was make it call javascript.
> Should the following work? (It doesn't seem to)
>
> Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnGetData.Click
> LoadGridView()
> ForcePageRefresh()
> End Sub
>
>
> Sub ForcePageRefresh()
> Dim popupScript As String
> Dim instance As ClientScriptManager
>
> instance = Page.ClientScript
> popupScript = "<script language='JavaScript'>"
> popupScript = popupScript & "
> window.location.reload( true );"
> popupScript = popupScript & "</script>"
> instance.RegisterStartupScript(GetType(String), "PopupScript",
> popupScript)
> End Sub



 
Reply With Quote
 
COHENMARVIN@lycos.com
Guest
Posts: n/a
 
      05-04-2008
> > I have a button in my asp.net page (actually its in a user control
> > with a .ASCX suffix) called btnGetData. I'm trying to make it force a
> > refresh of my page. So what I did was make it call javascript.

>
> Hi
> I am intrigued as to why you want to do this. Could it be that you are
> trying to trigger execution of code on the host page when a User
> Control button is clicked?


The reason I wanted to force a refresh was that I noticed my gridview
was only showing up when the page was refreshed. It wasn't enough to
set its parameters and then do a 'databind' - the gridview would only
appear on a postback. I really don't understand why this is the case,
and even when I stepped through with the debugger everything seemed in
order - but the gridview would not appear. So I decided to cheat, and
force a refresh.
The page does use AJAX, and perhaps that has some bug that causes the
problem.
-- Marvin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM
Force image refresh Marco Maroni ASP .Net 1 07-21-2003 05:29 PM



Advertisments