Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

sharepoint: How to programmatically open a custom form

Posted on 2011-10-24
5
Medium Priority
?
947 Views
Last Modified: 2012-05-12
I have a custom list instance. I used SharePoint Designer to create custom form which allows users to add new items. I wish to create a webpart with a button (-> opens my custom form). Basically: How to use c# to dipslay a form? I am using SharePoint 2010.
0
Comment
Question by:tolppa
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
ivan_vagunin earned 2000 total points
ID: 37017727
Hi! First you should know url of your custom form (I guess you can see it in SPD).
Then the link to open form in popup will be following: javascript:SP.UI.ModalDialog.ShowPopupDialog('{FormUrl}?ID={ItemId});
0
 
LVL 1

Author Comment

by:tolppa
ID: 37017881
Thanks, ivan.  I know my local url, but I would like to create solution that allows can be deployed to different machines / site collections etc. Perhaps I should use c# to generate this url, but then again, why not to use c# to open the form at the first place? Is that something I need to use javascript to do?
0
 
LVL 18

Expert Comment

by:ivan_vagunin
ID: 37017935
Let me explaing, if you want form to open in popup window the only way is to use execute javascript. There are two ways to execute javascript - on user action (e.g. button click) or register a startup script from server code. I guess registering startup javascript is more difficult, then just add onclick javascript hanlder for the button.

But, if you want to open list form in the same window (not popup) you can use Response.Redirect() in server code - to redirect user to custom form.
0
 
LVL 1

Author Comment

by:tolppa
ID: 37022718
Thanks. I believe you solved my problem. How to find ItemId (ID={ItemId})? Expecially guids keep giving me a head ache.
0
 
LVL 18

Expert Comment

by:ivan_vagunin
ID: 37022778
ItemId is not guid (unique id), but integer ID - you can add ID column in listview and see IDs for items.
For example http://myserver/Lists/MyList/MyForms.aspx?ID=1
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

580 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