last day (20 days later) » 

1:44 PM
hey
 
Jay
HI Jammykam..
sorry I don't know exactly your name
how have you been??
 
 
1 hour later…
3:16 PM
Hey. It's Kamruz. I;m not hard to find through google :)
I'm good thanks, quite busy with work sometimes, quite bored others :D
How are you? How are you finding Sitecore?
 
Jay
haha
thank you for letting me know.
I'm also busy due to Sitecore..... :)
but it is fun once I figure out some my brain issue..
I have a question about MVC and I'm really stuck on it.. Nobody could help me.. Could you see what the probelm is?
http://stackoverflow.com/questions/31484522/sitecore-mvc-field-update-programmatically
I have not gotten any correct answer I want..
 
3:33 PM
I did see the question. What type is your model ?
Do you have a custom model?
 
Jay
type?
yes I have custom model for the component
 
Ahh ok, I think i see what you are trying to do... you are tying to find the equivelent of ASP.Net WebForms OnClick Event, correct ?
 
Jay
yes. I want to update the field(checkbox) when it is submitted on page editor.
my concept is:
When check or uncheck the field in page editor,
Then form data goes to controller,
Then update the field in code-behind.
In view, content author can see update checkbox in page editor
 
Mmm...
What is the checkbox for?
It obviously relates to a Sitecore field, but why not let Sitecore handle the check/uncheck rather than manually handling this?
(I know Sitecore is not Page Editor friendly for this type of field, but there is a "work around")
 
Jay
I want content authors update field values in Page Editor, not Content Editor.
Content authors to update*
ok. This is rendering component. Rendering component's datasource item has checkbox field name "Enable Hover" for slideshow. On Page Editor, there are the same types of fields so that content author update fields without accessing Content Editor.
 
3:43 PM
Yes, I understand.
Two options:
1. Move the checkbox to a rendering parameter
This will allow the user to set the "Enable Hover" on a per control basis
but you need to access the field slightly different
 
Jay
In this case, if I use rendering parameter, I have to open the component property pop-up to update fields, right?
 
Yes
 
Jay
Is there any way to update directly on the Page Editor page?
I could get all set field value when Page Editor loads.
But, the updating on the page is problem..
 
2. Use EditFrame, but you still have a pop-up
Both these methods are the "Sitecore Standard" way of doing this
 
Jay
yeah....
I have also checked using EditFrame, but it was not my reach point...
basically, do you think my concept is possible??

When check or uncheck the field in page editor,
Then form data goes to controller,
Then update the field in code-behind.
In view, content author can see update checkbox in page editor
 
3:50 PM
It should be... but I wouldn't do posts from Sitecore Page Editor to update content
 
Jay
can I ask why?
 
Usually you are working with components, many components on a single page + additional Sitecore Page Editor context. For me it could get complicated, esp when you have the same component twice on a page it can get complex
That may not be the case for you though
For me, this is something that should go into Rendering Parameter
"Rendering component's datasource item has checkbox field name "Enable Hover" for slideshow"
That says to me that the user has to select a Datasource item. Rendering Parameters is on the same pop-up so the user should set them both together
 
Jay
yes. for the additional information.
 
So for me this is styling, and styling always goes in Rendering Parameters to allow each instance of a component to be styled separately
Back to your original issue...
Did you read these 2 posts?
 
Jay
yes I read..
 
3:57 PM
Essentially, you need to mark your Action with [HttpPost]
[HttpPost]
public ActionResult EditCar(CarViewModel viewModel)
{
// Do your saving here
// Redirect to another Sitecore page
}
 
Jay
yes. if I don't put the HttpPost, it automatically set HttpPost and I could see the form attribute's method as POST.
 
OK, so it is hitting your breakpoints then
 
Jay
hmmm when I add the [HttpPost], it gave me an error..
So, I make it comment out.
 
4:13 PM
Not sure why.
BTW
Your formHandler is incorrect / the wring way round
@Html.Sitecore().FormHandler("Components", "testController") <<<<<<<<
With the sample you have given
It should be:
@Html.Sitecore().FormHandler() ("test", "Components")
 
Jay
where is "test" from??
 
testController
You don't need the word controller
 
Jay
oh~
 
Oh sorry
 
Jay
actually its ActionResult name is "testController"
 
4:16 PM
my mistake
 
Jay
it is fine
I have added
like this, and no error..
 
Just noticed that
 
Jay
The last point is that how to know if Submit was clicked or not in Controller.
 
There is no click / not cicked
If you post to that controller then it was clicked / submitted
There's no other way to get to the controller action
(Hence the reason you add the HttpPost attribute)
 
Jay
ok understand
 
4:18 PM
What was the error you were getting?
 
Jay
I have not seen any error this time.. .
hmmm.. you mean there is not condition for submitting button in controller.
not ==> no*
 
Thats correct, there is no condition
It is not the same concept as it is with WebForms
 
Jay
hu....
 
It is possible to do this

[HttpPost]
public ActionResult GetCar(int id)
{
// do something
}

[HttpGet]
public ActionResult GetCar(int id)
{
// do something different
}
And each action is handled separately / differently
 
Jay
oh. In HttpPost, get all form data and if there is any parameter match in HttpGet, then update?
 
4:34 PM
No, they are 2 separate methods, just showing you that a post can be handled by a different method than get
even though they are called the same
 
Jay
yes
 
So there is no OnClick handler in MVC
 
Jay
okay
 
But, I still think your easiest solution is to have the checkbox in the Rendering Parameters or EditFrame
 
Jay
yeah..
 
4:35 PM
:)
 
Jay
Thank you so much Kamruz.
I really appreciate..
 
I have to go now, just finished work
Good luck
 
Jay
haha thx man~~
 
no problem
 
Jay
I think you live in England..
 

  last day (20 days later) »