INFO KONTAK UNTUK KURSUS SEO DAN JASA SEO
Alamat Kantor :
JL. KALIJUDAN MADYA 1 NO 48 SURABAYA
Pin BBM : 7C206484
LINE : 085101583088 / ID Line chrismaufuk123
CONTOH ARTIKEL SEO
Allowing admin to edit content
So far we have a data structure and the way to display the content on a page. Now let's move on to how the administrator / webmaster can manage the content of home page.
Step 1. Create a page EditContent.aspx in your project. (right click on your project and add a new webForm or page)
Step 2. Extract FckEditor.dll from FCKEditor files you downloaded in Part 1 and place them in the Bin director of your website project
Step 3. Include reference of FckEditor.dll in your project. (See the screen shot 'Add Ref')
Step 4. Include FCKEditor tag within EditContent.aspx page (Help: ) and name it fckContent
Step 5. Go to the codebehind now (EditContent.aspx.cs) write this code in the Page_Load event
If(! Page.IsPostBack) //this will make sure we only load content when page loads for the first time
string strSql = 'select * from tblPages where PageTitle='Home Page' ";
DataSet dsContent = OleDbHelper. ExecuteDataset('CONNECTION STRING FROM WEB.CONFIG',CommandType.Text,strSql);
fckContent.Html = dsContent.Tables.Rows['PageBody"].ToString();
Notice we are using .Html and not .Text, because the FCKEditor does not have a property called .Text, it has .Html.
At this time when you run your application and view the EditContent.aspx page, your website will query the table, tblPages, and bring back the content for Home Page into FCKEditor.
Now its time to create 'Update" button on FCKEditor to save the changes webmaster is going to be making.
Step 1. Create a button under the FCKEditor on EditContent.aspx and name it btnUpdate
Step 2. Double click the button and view its click event. Once you see the code behind, enter this code
string strSql = 'Update tblPages set PageBody='0' where PageTitle='Home Page' ';
strSql = string.format(strSql, fckContent.Html.ToString());
OleDbHelper. ExecuteNonDataset('CONNECTION STRING FROM WEB.CONFIG',CommandType.Text,strSql);
Response.Redirect('EditContent.aspx",true);Notice we are using ExecuteNonDataset method because we are only updating and we do not need anything back. Right after we update the content we send user back to the same page. This will make sure the new content loads in your FCKEditor and the administrator / webmaster can see that the changes are saved