Mvc 4 checkbox
i have a problem with saving multiple checkbox selection in the database
Checkboxes are the same in MVC 4 as before, you just need to know how to bind them properly.
Easiest way is to use the HTML helpers:
@Html.CheckBoxFor(m => m.BooleanField)
That's pretty much it for a single field.
Binding a List of Values to Checkboxes in MVC is a little bit trickier.
Similar Messages
-
BSP Tree View - how to create checkboxes on each node?
Hello all,
On my (non-MVC) BSP page I'd like to have a tree in which each node has a checkbox that the use can select, e.g. node 1.1: X, node 1.2: space; node 1.3: X
It doesn't seem like the standard <htmlb:tree> can do this. Is there any quick way I can achieve this functionality?
Any suggestions/code samples will be appreciated.
Rgds,
Louis.Hi Louis,
Go through the sample program which is exactly as per your requirement,
http://www.sapdevelopment.co.uk/webapps/bsp/bsp_orgunit.htm
Regards,
Azaz Ali. -
Check teh checkboxes on click of button
Hi,
I am using mvc bsp application.
I have a button "select all" . upon clicking this button i need to check certain checkboxes.how do i do this using onclientclick and javascript?
Regards,
niky.<af:commandButton partailSubmit="true" id="cb1" actionListener="#{Bean.doAction}">
<af:inputText partialTriggers="cb1" visible="#{Bean.flag}">
in the bean have it like
private boolean flag; //have getter and setter
public void doAction(ActionEvent actionEvent){
flag=true; -
Hi, I'm trying to implement a menu bar with menus and submenus, all of which contain only basic JMenuItems (i.e., no checkboxes, radiobuttons, etc.). The twist here is I'd like to use MVC (Model-View-Controller), where there is a "menu model" to handle updates, similar to JTree with an underlying TreeModel.
May I know if someone has already implemented this before, or know of a framework for this? I've googled using the keywords menu, jmenubar and model, but without any luck...
Thanks in advance.Thanks, I'll have a good read over that later.
I notice that Java has a lot of pre-defined interfaces and abstract classes for things I'd usually go ahead and write myself in other languages. To avoid wasting time re-inventing the wheel which of the commonly used patterns below already provide the necessary interfaces? :)
* Singleton (yuck -- I avoid this where I can)
* Registry
* Observer (I know this does)
* MVC
* Prototype
* Strategy
* Data Mapper
* DI
A bit out of scope for this thread I guess. -
Hi All,
I have a MVC-BSP and Iu2019m looking for the information how can I link this BSP (like a logical link) in the crm2007.
Can anybody help me?
Thanks & RegardsHi,
According to ur requirement u need to create a transaction launcher for ur BSP-MVC . Follow the bellow steps.
1. Define URL parameters for transaction launcher for ur BSP application and pass ur main controller name and main page name like
Application - MAIN.Do
Page - MAIN.HTM
2. Create a transaction launcher of URL type and pass URL parameter id over there.
3. After follow all steps for transaction launcher like logical link, assign logical link id to direct link group and assign to navigation bar profile.
4. In ur business role check the checkbox for this logical link from visible direct link.
Now test ur transaction launcher. It will work.
Regards
Gaurav -
hi,
i want to delete the data which r fetched into the table from the database table.my backend is sql server 2000.i hav checkbox in front of each row.and i want to delete the data of that row when the user clicks on that checkbox.i hav delete button on that page.when i click the delete button another jsp page is called which is fdelete.jsp.delete procedure is written in fdelete.jsp.i am not able to delete the data which r checked.
out.println("<input type='checkbox' name=? value=?>" unchecked);
i dont know what to write in the checkbox name to get the unique identity.
plz help it urgent.hi,
i want to delete the data which r fetched into the
table from the database table.my backend is sql
server 2000.i hav checkbox in front of each row.and i
want to delete the data of that row when the user
clicks on that checkbox.i hav delete button on that
page.when i click the delete button another jsp page
is called which is fdelete.jsp.delete procedure is
written in fdelete.jsp.i am not able to delete the
data which r checked.
out.println("<input type='checkbox' name=? value=?>"
unchecked);
i dont know what to write in the checkbox name to get
the unique identity.
plz help it urgent.Hi,
my openion abt your problem is that, write a js function which will extract all that checked boxes or get such values in servlet. and retrives the unique id let me say the row whic you are going to delete is having a uniquely identified key someting like primary key. get such type of values... and the write the querty something like DELETE FROM tablename WHERE id="checked value"; try to use MVC pattern. which is easy to understand and to implement/modify the problem without effecting other code. -
Checkboxes remain set when looping over screen
Hi there,
I have got a problem with some checkboxes on a BSP with MVC.
I am creating an extension for cProjects within a single tabStrip.
My BSP constist of several checkboxes and I want to loop over this screen for some times to collect data. For every call of the BSP I create a new instance, set page attributes and call the view in DO_REQUEST. The page attributes cause some checkboxes to be set. This works fine so far.
My problem is that checkboxes that were selected on the previous screen remain selected.
I think this happens because the checkboxes have the same names as those on previous screens.
How can I disable this behaviour? I would appreciate your help.Hi Raja,
thanks for your friendly welcome!
My BSP is already stateless. It is for assigning test
types to components in a production project and for
assigning standards to these test types. So there are
some nested groups with checkboxes.
First I loop over some existing test types and standards which will be displayed as 'checked' and the checkboxes are disabled. This works great so far.
<%@page language="abap" %>
<%@extension name="bsp" prefix="bsp" %>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="xhtmlb" prefix="xhtmlb" %>
<%@extension name="phtmlb" prefix="phtmlb" %>
<xhtmlb:overflowContainer>
<htmlb:button id = "test_comp_next"
text = "Next"
tooltip = "Go to next step in Task Wizard"
onClick = "test_comp_next"
design = "EMPHASIZED" />
<br />
<htmlb:textView text = "Component Validation"
design = "EMPHASIZED" />
<br />
<htmlb:group>
<htmlb:groupHeader>
<htmlb:textView text = "<%= ms_component-task_descr %>"
design = "EMPHASIZED" />
</htmlb:groupHeader>
<htmlb:groupBody>
<table cellpadding="5" valign="TOP" >
<tr>
<%
mv_counter = 0.
loop at mt_test_types_available into ms_test_type_available.
read table mt_test_types into ms_test_type with key task_type = ms_test_type_available-test_type.
if ms_test_type is not initial.
mv_counter = mv_counter + 1.
%>
<td valign="TOP">
<htmlb:group width="110px" >
<htmlb:groupHeader>
<htmlb:textView text = "<%= ms_test_type-task_type %>"
design = "EMPHASIZED" />
</htmlb:groupHeader>
<htmlb:groupBody>
<%
loop at mt_standards_available into ms_standard_available.
if ms_standard_available-test_type = ms_test_type-task_type and ms_component-task_type = ms_standard_available-task_type.
read table mt_standards into ms_standard with key task_type = ms_standard_available-product_std parent_guid = ms_test_type-task_guid.
if ms_standard is not initial.
%>
<htmlb:checkbox id = "<%= ms_standard-task_type %><%= mv_counter %>"
text = "<%= ms_standard-task_type %>"
checked = "TRUE"
disabled = "TRUE" />
<br />
<%
clear ms_standard.
After displaying the already existing standards I also display other standards that are available for a component and might be selected.
else.
%>
<htmlb:checkbox id = "<%= ms_standard_available-product_std %><%= mv_counter %>"
text = "<%= ms_standard_available-product_std %>"
key = "<%= ms_test_type-task_type %>" />
<br />
<%
endif.
endif.
endloop.
%>
</td>
</htmlb:groupBody>
</htmlb:group>
<%
else.
After that I also loop over test types that are not existing yet. They and their corresponding standards can be selected in addition.
mv_counter = mv_counter + 1.
%>
<td valign="TOP">
<htmlb:group width="110px" >
<htmlb:groupHeader>
<htmlb:textView text = "<%= ms_test_type_available-test_type %>"
design = "EMPHASIZED" />
</htmlb:groupHeader>
<htmlb:groupBody>
<%
loop at mt_standards_available into ms_standard_available.
if ms_standard_available-test_type = ms_test_type_available-test_type and ms_component-task_type = ms_standard_available-task_type.
%>
<htmlb:checkbox id = "<%= ms_standard_available-product_std %><%= mv_counter %>"
text = "<%= ms_standard_available-product_std %>"
key = "<%= ms_test_type_available-test_type %>" />
<br />
<%
endif.
endloop.
%>
</td>
</htmlb:groupBody>
</htmlb:group>
</td>
<%
endif.
endloop.
%>
</tr>
</table>
</htmlb:groupBody>
</htmlb:group>
</xhtmlb:overflowContainer>
Message was edited by:
Stefan Grosskinsky
Message was edited by:
Stefan Grosskinsky
Message was edited by:
Stefan Grosskinsky
Sorry I have got some problems with formatting my code.
Message was edited by:
Stefan Grosskinsky
Message was edited by:
Stefan Grosskinsky -
Checkbox item: How to get all values checked?
See http://htmldb.oracle.com/pls/otn/f?p=24317:46
The report query is simply
select
'One' one,
'Two' two,
'Three' three,
'Four' four
from dualThe checkbox item is a named static LOV with STATIC2:ONE,TWO,THREE,FOUR and a Source value of ONE:TWO:THREE:FOUR so that all boxes appear checked when the page is first rendered.
All the 4 columns have a column condition like
instr(':'||:P46_COLS||':',':ONE:') > 0to ensure that column is rendered only if the corresponding checkbox is checked.
The report has Dynamic column headings with the following PL/SQL function body
return 'ONE:TWO:THREE:FOUR';To my (pleasant) surprise, this works very nicely. When column TWO is conditionally not rendered, its corresponding column heading is also skipped with no effort on my part. Nice.
Question:
Instead of "hard-coding" that string ONE:TWO:THREE:FOUR in the 2 places I mentioned above (checkbox item source and report heading), is there a way to access the "all values checked" version of that LOV item so that it will dynamically pick up the latest LOV changes? The way I have done it currently, if I change the named LOV, I need to also change those 2 places where I have hardcoded the values.
Any ideas? ThanksScott:
I thought about that but the LOV has dozens of values, each with a verbose display value and a return value of the column name (upto 30 characters) and the display values are still being "worked on" by the users.
So, the "all columns" string would be a big, unweildy string that would be hard to edit.
It is much easier to edit, resequence and generally work with a Shared Component LOV defined as a Static LOV because you get that nice page (4000:4111) where you can read everything nicely formatted instead of a STATIC2:<big long string>!
Can I have my cake and eat it too?!
Thanks -
Use of Checkbox in Report for calculation and determine checked records
Dear All,
Application Express 4.0.1.00.03
I have a Report based on Invoice table which displays unpaid Invoices.
Also I have added one check box (Not a column in Invoice field) to each row of the report query, the user will be check to pay the Invoice, on checking of the Invoices I need to
1. Calculate the total of Invoice Amount for selected Invoices.
2. After selection of Invoices User will click on a Button which will open the Payment Form (New Page or Same Page Region),
but some way I need to know the Invoice No. of each Invoice row selected so that I can use all the selected Invoice No's for creating the Payment.
3. Any way to add a button on each row of the Invoice that will be used for the Payment of that Invoice only.
One way can be to create a column to save the check box value which I am aware of, but am looking for other alternate if possible.
Hoping for some good solution.
Thanks & Regards
Arif Khadasvee wrote:
You would need to make the amount column(the one which is used for total) editable so that its value can be accessed easily from JS. You can made it read-only if required ( apex_item.text(2,INV_RENT_VALUE + INV_OTHER_VALUE ) ?? ) .
How can I make it read only, there is no such attribute which can be set for report column as it exists for Items.
Also Now I have the following report query:
SELECT INV_LSE_NUM "Contract No.",
INV_FROM_DATE "Collection Date",
INV_FROM_DATE "From Date",
INV_TO_DATE "To Date",
INV_RENT_VALUE + INV_OTHER_VALUE "Invoice Amount",
INV_AMOUNT_PAID "Amount Paid",
INV_RENT_VALUE + INV_OTHER_VALUE
- INV_AMOUNT_PAID "Balance",
INV_NUM "Invoice No.",
'Pay' "Pay",
APEX_ITEM.CHECKBOX (1, INV_NUM) "CB_PAY",
APEX_ITEM.TEXT (2, INV_RENT_VALUE + INV_OTHER_VALUE - INV_AMOUNT_PAID)
"BAL"
FROM RE_INVOICE
WHERE INV_COM_NUM = :P0_COM_NUM
AND INV_RENT_VALUE + INV_OTHER_VALUE > INV_AMOUNT_PAID
AND INV_LSE_NUM =(SELECT TO_NUMBER (C001)
FROM APEX_COLLECTIONS
WHERE COLLECTION_NAME = 'LEASE'
AND SEQ_ID = TO_NUMBER (:P24_SR_NO))The Next thing is the HTML Header for the Page:
<script language = "JavaScript" type="text/javascript">
total = 0;
$('input[name=f01]:checked').each( function(){
parent_row = $(this).parents('tr:first');
amt = ( parent_row.find('input[name=f02]').val() == ' ') ? 0 : parseFloat(parent_row.find('input[name=f02]').val() );
total += amt;
$s('TEST',total); -- Test is an Item on the Page.
</script>Also I checked from the Page source "CB_PAY" and "BAL" have names f01 and f02 respectively.
Even now when I check or un-check the Value in TEST item is not displayed as required.
Anything more is required, what am I missing.
Thanks & Regards
Arif Khadas -
hi expert,
i create report with check box at begin of write data in tab. after execute, i get report like this
1 (checkbox) xxxxx x xxx xxxxxxxxxxxxxxxx
2 (checkbox) xxxxx x xxx xxxxxxxxxxxxxxxx
3 (checkbox) xxxxx x xxx xxxxxxxxxxxxxxxx
4 (checkbox) xxxxx x xxx xxxxxxxxxxxxxxxx
when user select check box of desire line and press F8 button system will display only selected line.so i set check box default as 'X'.
Data:
chk_box type c value 'X',
chk_box_val,
write:/1 1tab-xxxxx,
30 chk_box as checkbox
like this all checkbox in report is checked
so i will update field in 1tab to flag that this line is select. if user execute report and don't unmark, all line should display in second execute.
but it don't, nothing display. where is incorrect in my code? for easy to look, this is a relative part of code in my report.
at line-selection.
perform selectline.
at pf8.
perform printnewheader.
perform printselectline.
form selectline.
data xnum like rmtab-runno.
read current line field value chk_box into chk_box_val.
if chk_box_val is initial.
chk_box_val = 'X'.
else.
chk_box_val = space.
endif.
modify current line field value chk_box from chk_box_val.
if chk_box_val = 'X'.
xnum = 1tab-runno.
loop at 1tab where runno = xnum.
1tab-chk = 'X'.
modify 1tab.
clear 1tab.
endloop.
else.
xnum = 1tab-runno.
loop at 1tab where runno = xnum.
clear 1tab-chk.
modify 1tab.
clear 1tab.
endloop.
endif.
endform. " selectline
form print-doc-select.
loop at 1tab where chk = 'X'.
write:/ ................
endform.
once i arrange code like this, but it's nothing
*at line-selection.
* perform selectline.
at pf8.
perform selectline.
perform printnewheader.
perform printselectline.
(later is as same as above quote)
thank you in advance. point for good advise.
Regards,
Kittisak.HI,
First you have to describe the number of lines in list.TO do this
declare like this
And I modified your code. and dont mention the default value for check box.U can select dynamically by using the below code.It gives a good user interface. Based on the below code u can modify your code .Please check it out once...
data:
w_lines type i, " number of lines
w_linno type i. " line number
at line-selection.
perform selectline.
at pf8.
perform printnewheader.
perform printselectline.
form selectline.
data xnum like rmtab-runno.
describe list number of lines w_lines.
do w_lines times.
read current line w_lineno value chk_box into chk_box_val.
if chk_box_val is initial.
chk_box_val = 'X'.
else.
chk_box_val = space.
endif.
modify current line w_linno value chk_box from chk_box_val.
if chk_box_val = 'X'.
xnum = 1tab-runno.
loop at 1tab where runno = xnum.
1tab-chk = 'X'.
modify 1tab.
clear 1tab.
endloop.
else.
xnum = 1tab-runno.
loop at 1tab where runno = xnum.
clear 1tab-chk.
modify 1tab.
clear 1tab.
endloop.
endif.
clear chk_box .
add 1 to w_linno.
enddo.
endform. " selectline
form print-doc-select.
loop at 1tab where chk = 'X'.
write:/ ................
endform.
regards
Kiran
Edited by: Kiran Saka on Feb 6, 2009 5:50 AM -
Open and display image in MVC layout
Hello!
I cant figure out how I shall do this in an MVC layout:
The program request user to open an image file that are then displayed in a JLabel
My setup at the moment resolve in a nullpointerexeption because it dont get any actual image file, but I dont understand what I have missed.
I can not post the whole code fo you to run because it is to big, so I post the part that are the most important. please have a look.
PicturePanel
//Import Java library
import javax.swing.*;
import java.awt.*;
public class PicturePanel extends JPanel {
//Variables
private ImageIcon picture;
//Method to get information of the selected file
PicturePanel (String fileName) {
picture = new ImageIcon (fileName); //Get the filename
int w = picture.getIconWidth(); //Get the image with
int h = picture.getIconHeight(); //Get the image height
//Set preferable size for the image (Use the properties for the selected image)
setPreferredSize(new Dimension(w, h));
setMinimumSize(new Dimension(w, h));
setMaximumSize(new Dimension(w, h));
//Method to draw the selected image
protected void paintComponent(Graphics g) {
super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
}From my model:
//Local attributes
boolean check = false; //Used to see if a statement is true or not
PicturePanel pp;
JFileChooser fc;
int returnVal;
//newFile in File menu
public void newFile() {
//Open a file dialog in users home catalog
fc = new JFileChooser();
//In response to a button click:
returnVal = fc.showOpenDialog(pp);
System.out.println("You pressed new in file menu");
}From my controler:
//User press "New" in File menu
else if (user_action.equals("New")) {
//Call method in model class
model.newFile();
//Update changes
if (model.returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("Hello1");
File f = model.fc.getSelectedFile();
if (model.pp != null)
model.pp = new PicturePanel(f.getAbsolutePath());
System.out.println("Hello2");
//Display image (Here is line 83)
view.setImage_DisplayArea(model.pp);
System.out.println("Hello3");
}From my view:
//Sets the image to be displayed on the image_display area (Here is line 302)
public void setImage_DisplayArea(PicturePanel pp) {
image_display.add(pp);
}The complet error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1015)You pressed new in file menu
Hello1
Hello2
at java.awt.Container.add(Container.java:351)
at View_Inlupp2.setImage_DisplayArea(View_Inlupp2.java:302)
at Control_Inlupp2.actionPerformed(Control_Inlupp2.java:83)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1050)
at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1091)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)Edited by: onslow77 on Dec 16, 2009 5:00 PM
Edited by: onslow77 on Dec 16, 2009 5:04 PMHello again!
Anyone that can help me figure out how to implement this in an MVC layout, I feel stuck.
I post a little program that open and display an image file so that you better can understand what I whant to do.
ShowImage
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.filechooser.*;
public class ShowImage extends JFrame{
//Variables
JFileChooser fc = new JFileChooser();
PicturePanel pp = null;
ShowImage () {
super("Show"); //Title
//Create the GUI
JPanel top = new JPanel();
add(top, BorderLayout.NORTH);
JButton openBtn = new JButton("Open");
top.add(openBtn);
openBtn.addActionListener(new Listner());
//Settings for the GUI
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setVisible(true);
class Listner implements ActionListener {
public void actionPerformed(ActionEvent ave) {
int answer = fc.showOpenDialog(ShowImage.this);
if (answer == JFileChooser.APPROVE_OPTION){
File f = fc.getSelectedFile();
//Check
System.out.println(f);
System.out.println(pp);
if (pp != null)
remove(pp); //Clean so that we can open another image
//Check
System.out.println(pp);
//Set the PicturePanel
pp = new PicturePanel(f.getAbsolutePath());
//Check
System.out.println(pp);
//Add PicturePanel to frame
add(pp, BorderLayout.CENTER);
validate();
pack();
repaint();
//Main
public static void main(String[] args) {
new ShowImage();
}PicturePanel
//Import Java library
import javax.swing.*;
import java.awt.*;
public class PicturePanel extends JPanel {
//Variables
private ImageIcon picture;
//Method to get information of the selected file
PicturePanel (String fileName) {
picture = new ImageIcon (fileName); //Get the filename
int w = picture.getIconWidth(); //Get the image with
int h = picture.getIconHeight(); //Get the image height
//Set preferable size for the image (Use the properties for the selected image)
setPreferredSize(new Dimension(w, h));
setMinimumSize(new Dimension(w, h));
setMaximumSize(new Dimension(w, h));
//Method to draw the selected image
protected void paintComponent(Graphics g) {
super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
}//The endEdited by: onslow77 on Dec 16, 2009 7:30 PM -
Using a Radio Button to Disable Multiple Checkboxes
Hi everyone,
My name is Christian and I am trying to design a form using Adobe Designer 7 that when a user selects a group of two radio buttons (one marked Macintosh and one marked Windows) it automatically disables 3 or 4 checkboxes of various software applications further down the page.
The idea is if you select the Windows radio button, you would not be able to select the iWorks or StuffIT checkboxes (as that is Mac software), but conversely if you check Macintosh radio button the iWorks and StuffIT checkboxes activate but the Office 2003 and Microsoft Money checkboxes deactivate (because that is Windows software).
Im not really a developer so any assistance would be appreciated. Thanks for reading and have a great day! :-)
ChristianI suspect that you have a problem in some portion of your code that you have not posted. To help debugging I suggest you create a simple test using two pages: input.cfm and action.cfm. Get the most simple case working then add the javascript, css, and CF code to make your application work.
<!--- contents of input.cfm --->
<html>
<head>
<title>Input</title>
</head>
<body>
<form action="action.cfm" method="POST">
Choose type: <br />
<input name="type" type="radio" value="male" /> Male<br />
<input name="type" type="radio" value="female" /> Female<br />
<input type="submit" />
</form>
</body>
</html>
<!--- content of action.cfm --->
<html>
<head>
<title>Action</title>
</head>
<body>
<cfif form.type eq "male">
Type is male.
<cfelseif form.type eq "female">
Type is female.
</cfif>
Here is a cfdump of the form variables:<br />
<cfdump var="#form#" />
</body>
</html>
Message was edited by: JR "Bob" Dobbs
Added sample for action.cfm -
How can I create a new table in a MySQL database in MVC 5
I have an MVC 5 app, which uses MySQL hosted in Azure as a data source. The point is that inside the database, I want to create a new table called "request". I have already activated migrations for my database in code. I also have the following
code in my app.
Request.cs: (inside Models folder)
public class Request
public int RequestID { get; set; }
[Required]
[Display(Name = "Request type")]
public string RequestType { get; set; }
Test.cshtml:
@model Workfly.Models.Request
ViewBag.Title = "Test";
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>
@using (Html.BeginForm("SaveAndShare", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
@Html.AntiForgeryToken()
<h4>Create a new request.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.RequestType, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.RequestType, new { @class = "form-control", @id = "keywords-manual" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Submit!" />
</div>
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
HomeController.cs:
[HttpPost]
public ActionResult SaveAndShare(Request request)
if (ModelState.IsValid)
var req = new Request { RequestType = request.RequestType };
return RedirectToAction("Share");
The point is that, I want the user to fill the form inside the Test view and click submit, and when the submit is clicked, I want a new entry in the new table to be created. But first of course I need to create the table. Should I create it using SQL query
through MySQL workbench? If yes, then how can I connect the new table with my code? I guess I need some DB context but don't know how to do it. If someone can post some code example, I would be glad.
UPDATE:
I created a new class inside the Models folder and named it RequestContext.cs, and its contents can be found below:
public class RequestContext : DbContext
public DbSet<Request> Requests { get; set; }
Then, I did "Add-Migration Request", and "Update-Database" commands, but still nothing. Please also note that I have a MySqlInitializer class, which looks something like this:
public class MySqlInitializer : IDatabaseInitializer<ApplicationDbContext>
public void InitializeDatabase(ApplicationDbContext context)
if (!context.Database.Exists())
// if database did not exist before - create it
context.Database.Create();
else
// query to check if MigrationHistory table is present in the database
var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery<int>(
string.Format(
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'",
// if MigrationHistory table is not there (which is the case first time we run) - create it
if (migrationHistoryTableExists.FirstOrDefault() == 0)
context.Database.Delete();
context.Database.Create();Hello Toni,
Thanks for posting here.
Please refer the below mentioned links:
http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/
http://social.msdn.microsoft.com/Forums/en-US/3a3584c4-f45f-4b00-b676-8d2e0f476026/tutorial-problem-deploy-a-secure-aspnet-mvc-5-app-with-membership-oauth-and-sql-database-to-a?forum=windowsazurewebsitespreview
I hope that helps.
Best Regards,
Sadiqh Ahmed -
How to get background color in MVC programming
Hi Experts,
I am new to BSP.
I am working in CRM 7.0 version and designing a view using MVC method in BSP.
I have two doubts::
1. How can i get background color in a view ?
2. How can i attach a picture, that is in paint-brush, in background ?
Thanks in Advance.
Nitin Karamchandani.
Edited by: Nitin Karamchandani on Jun 3, 2009 8:10 AMHi,
several html tags have the attribute bgcolor, like
<body bgcolor="red"> or <body bgcolor="RRGGBB"> where RR, GG, BB is an hexadecimal value according to RGB color palette.
you can also work with CSS and in this case you affect the attribute style, which is also available in several tags:
document.body.style.backgroundColor="#EEEEEE" -
Read-only radio button or checkboxes save as null
Hi,
I have a form with some fields that are editable by 1 group of users and read-only for another group in certain conditions.
Before the header there is a fetch process to retrieve values from tables. So most fields (read-only & editable) are populated including checkboxes & radio buttons.
All users can edit at least 1 field on the form.
When the save button is pressed a PL/SQL process runs to save the data.
The save works if the field is editable.
If the field is read-only and text it also works.
But if the field is a radio button or checkbox a null is saved in the table.
Any suggestions on how to get the PL/SQL to pick up the read-only radio buttons and checkbox values?Hi,
I had the same problem in my application and I found another solution instead of using two items. I'm using a computation on page processing that makes a select on my table to get the value for the checkbox. I'm doing this with the same condition as my read-only condition on my checkbox item so I can get the database value when it is lose in the submit process.
Also, I found a difference in the html code between the read-only state of the item and the standard state.
Original state : name="p_v07" (7 because it's the seventh item on my page)
Read-only state : name="checkbox"
I tried to modify this using firebug in execution of the page but without success, the problem is still there.
Patrick
Insum Solutions
Maybe you are looking for
-
HSDIO - Deterministic memory writing while generating
Hello, I am using an HSDIO card (PXI 6542) to drive a device (DUT) with a predefined fixed length continuously running waveform. That DUT might actually benefit from some dynamic changes in the digital signals depending measurements made on the DUT i
-
Hi! Is there a way to delete row in database table by telling the number of the row? Thanx!
-
How can I set up icloud phote streaming to my home computer? When I follow their directions my comuter does not show the Icloud icon uner the control panel / netwrok internet
-
Can someone refresh my memory on how to convert a path into a selection?
-
ICalendar error message repeatedly popping up
I am trying to update my iCalendar and have an old deactivated gmail account set up with iCal. The calendar keeps automatically trying to sync the calendar and repeatedly failing, but the error message pops up EVERY time I close it, so I can't delete