33 var NumberOfComments = 10 ;
44 var widgetId = Request .QueryString [" id" ];
55 var settings = WidgetHelper .GetSettings (widgetId );
6-
6+ Validation .Add (" txtNumberOfComments" ,
7+ Validator .Required (" Field is required" ),
8+ Validator .Integer (" Field is numeric" )
9+ );
710 if (IsPost )
811 {
9- settings [" numberofcomments" ] = Request .Form [" txtNumberOfComments" ];
10- WidgetHelper .SaveSettings (settings , widgetId );
12+ if (Validation .IsValid () && settings [" numberofcomments" ] != Request .Form [" txtNumberOfComments" ])
13+ {
14+ settings [" numberofcomments" ] = Request .Form [" txtNumberOfComments" ];
15+ WidgetHelper .SaveSettings (settings , widgetId );
16+ @: < script type = " text/javascript" > window .parent .toastr .success (" Completed" );< / script >
17+ }
1118 }
1219 if (settings != null && settings .Count > 0 )
1320 {
1421 NumberOfComments = int .Parse (settings [" numberofcomments" ]);
1522 }
1623}
17- <link rel =" stylesheet" href =" ~/Content/bootstrap.min.css" >
18- <link rel =" stylesheet" href =" ~/admin/themes/standard/css/styles.css" >
19- <style >
20- body { background-color : #fff ; }
21- </style >
22- <form method =" post" >
23- <div class =" form-group" >
24- <label >@Resources.labels.numberOfComments </label >
25- <input type =" text" class =" form-control" id =" txtNumberOfPosts" name =" txtNumberOfComments" value =" @NumberOfComments" />
26- </div >
27- <div >
28- <button type =" submit" onclick =" window.parent.updateTitle()" class =" btn btn-success btn-sm pull-left" >
29- Save
30- </button >
31- </div >
32- </form >
24+ <!DOCTYPE html>
25+ <html >
26+ <head >
27+ <link rel =" stylesheet" href =" ~/Content/bootstrap.min.css" >
28+ <link rel =" stylesheet" href =" ~/admin/themes/standard/css/styles.css" >
29+ <style >
30+ body { background-color : #fff ; }
31+ .field-validation-error { background-color : #d9534f ; border-color : #d9534f ; color : #fff ; padding : 5px 15px ; display : block ; }
32+ </style >
33+ </head >
34+ <body >
35+ <form method =" post" >
36+ <div class =" form-group" >
37+ <label >@Resources.labels.numberOfComments </label >
38+ <input type =" text" class =" form-control" id =" txtNumberOfComments" name =" txtNumberOfComments" value =" @NumberOfComments" />
39+ @Html.ValidationMessage( "txtNumberOfComments")
40+ </div >
41+ <div >
42+ <button type =" submit" onclick =" window.parent.updateTitle()" class =" btn btn-success btn-sm pull-left" >
43+ @Resources.labels.save
44+ </button >
45+ </div >
46+ </form >
47+ </body >
48+ </html >
0 commit comments