0

In my project Button click action is not rendering as per the style provided So i tried two methods and both have screenshots attached.

1.<button type="submit" class = "btn btn-success">@Html.ActionLink("Save", "EmployeeRegistration",
"Home")</button> 
2.<button type="submit" >@Html.ActionLink("Save", "EmployeeRegistration", "Home",new{@class = "btn
     btn-success"})</button>

both have Style Issues ScreenShot for Method1

Screenshot for Method2

1
  • Are you using Bootstrap? Commented Jan 10, 2014 at 8:41

2 Answers 2

2

Just for a try, see what output the next line gives to you :-

<input type="submit" class = "btn btn-success" value="Save" />

Use only this :-

@Html.ActionLink("Save", "EmployeeRegistration", "Home", new{ @class = "btn
 btn-success"});

You were using Hyperlink within a button, that's why your button was dis aligned.

Use this style :-

.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.428571429;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
border-radius: 4px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
Sign up to request clarification or add additional context in comments.

5 Comments

When am using the above code Its working but the button text is not visible that means its not rendering as per the style.Thats problem
Add the CSS class in your stylesheet.
its already there...all css styles are loaded in the Layout page
that means your styles are overriding each other. you can find this by inspect element. Some a style is overriding your .btn class.
<input type="submit" class = "btn btn-success" value="Save" /> This one works Fine.Updated the Action name and Controller name like this...@using (Html.BeginForm("EmployeeRegistration", "Home",FormMethod.Post))
0

Try this

@Html.ActionLink("Save", "EmployeeRegistration", "Home", new{ }, new{@class = "btn
     btn-success"})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.