Solved

Problem With Refresh parent page after save data in dataview web part..

Posted on 2008-10-16
12
2,469 Views
Last Modified: 2010-04-21
Hii All,

  I did one dataview web part in sharepoint site. and i have one hyperlink to open newform.aspx. i open that form in another page like child page. and i removed sharepoint save and cancle button and i wrote code for save and cancel is .. <input Type="button" Value="Save" Onclick="javascript:{ddwrt:Genfireserverevent{'_commit';};window.opener.document.location.reload;self.close();>
So i used window.opener.document.location.reload for refresh and self.close(); for close child window.
But when i click SAVE button then first it refresh the parent window and then it save the data. so i dont get resule. everytime i have to refresh manually..

How can i fix this problem?? Can i refresh twise so i can remove this problem..Please anyone help me ..
And one more thing is an another list it works fine but only this project tasks list it does not work..

Thank You..
Dipesh
0
Comment
Question by:guessdip
  • 8
  • 4
12 Comments
 
LVL 6

Expert Comment

by:jyotisinha
Comment Utility
Dipesh
How about using var ret=window.showModalDialog instead of window.open?
If showModalDialog is possible, that offers more control over controling the postback at parent page. Based on save (successful or failed), you can return a true or false from popup page using window.returnvalue= <true or false>.
if true is returned, parent page's server event would be fired and your page will get reloaded.

Hope this helps!
0
 

Author Comment

by:guessdip
Comment Utility
Hii jyoti sinha,
 
   Exactly i used hyperlink for open pop window means newform like <a href http:abc.com?project=project1"Target=-blank...i used target = blank so it open this form in another window..i did not use show model or window.open...

I dont know what to do. exactly first it refresh the page and then save the data so i am not getting desire output. i need refresh again or try to set time or think about sequence of execute command..

What to do ??
Thanks
Dipesh
0
 
LVL 6

Expert Comment

by:jyotisinha
Comment Utility
Hope I am getting your question right! using showmodaldialog, you could do like this

1.) On parent page,
instead of using <a href http:abc.com?project=project1"Target=-blank
you can use following:

 <a href=# onClick='return openpopup();'>your link text</a>

In javascript write the following function:

function openpopup()
{
         var windowFeatures =
               'dialogWidth:800px; dialogHeight:500px; ' +
                'center:yes; help:no; resizable:no; status:no;';
             return window.showModalDialog(yourchildpageURL,' ',windowFeatures);
}

and
2.) on Child page, you can do following:
<input Type="button" Value="Save" Onclick="javascript:{ddwrt:Genfireserverevent{'_commit';};window.returnValue=true; window.close();>

Hope this works!
0
 

Author Comment

by:guessdip
Comment Utility
Hii,
   I am using sharepoint designer so i am using sxlt language so i am confuse to write javascript function. can i write code directly in hyperlink??i wrote but i got error...


Thanks..
0
 

Author Comment

by:guessdip
Comment Utility
Hii jyoti,

 When i write this  <a href=# onClick='return openpopup();'>your link text</a>
then i get error "" This web part does not have valid xslt style sheet :Error: A string literator was  expected;But no opening quota character found.""

Thanks
0
 

Author Comment

by:guessdip
Comment Utility
Hii jyoti,
  i used  <a href="#" onClick='return openpopup();'>your link text</a>
And i wrote fuction
But when i click on that link then page is not open.. Any idea ??
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:guessdip
Comment Utility
Hiii,
  i used your code it works fine for opening pop pup window and close but it is not refresh so i dont get data,i have to refresh manually...Any idea to refresh page after using showmodelwindow..


Thank You
Dipesh
0
 
LVL 6

Accepted Solution

by:
jyotisinha earned 500 total points
Comment Utility
oops!!! It requires server control with events on codebehind...
Two options I can see here...
1.) instead of <a href... , use a <ASP:linkbutton> control and you may keep the server side event of this linkbutton without any code, then when the openpopup returns true, it will try to execute the server side 'click' event of link button. Since you keep the server side event blank, so it will only postback the page and refresh that. OR
2.) If you can not do away with <a href..., then put a server side button control (button1)on page and make that visible false. Make sure, you have created button1_click event in code behind. Now, make a slight change in openpopup function. See, I have added __doPostBack in the end of the function.

function openpopup()
{
         var windowFeatures =
               'dialogWidth:800px; dialogHeight:500px; ' +
                'center:yes; help:no; resizable:no; status:no;';
             return window.showModalDialog(yourchildpageURL,' ',windowFeatures);
             __doPostBack("Button1","");
}

hope this works for you!
0
 

Author Comment

by:guessdip
Comment Utility
Hii jyoti,
  When i use showmodeldialog and when i close this then another normal window open with same url. so everytime i have to close this window. I used window.showmodeldialog(url,window,windowfeature)




thanks
Dipesh
0
 
LVL 6

Expert Comment

by:jyotisinha
Comment Utility
got it...in <head> section of aspx page,  just use
like <head>
 <base target ="_self"/>
</head>
0
 

Author Comment

by:guessdip
Comment Utility
Hii i already used,__self in hyperlink target property...
0
 

Author Closing Comment

by:guessdip
Comment Utility
Thanks Jyoti,,If you have time then just take a look of my new question..
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now