TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shomen Deb
NA
43
0
Generate Random Number in javascript & display in @Html.Editfor/@Html.Textboxfor
May 27 2012 6:06 AM
Hello,
I am developing a small project using Asp.net MVC3. I would like to generate a random number using javascript and send this number to @Html.Editfor or @Html.TextBoxfor. I can generate random number but I cannot pass this value to html textbox to display.
My code is like that:
@using (Html.BeginForm())
{
<div class="editor-field">
@Html.EditorFor(model => model.TrackingID)
@Html.ValidationMessageFor(model => model.TrackingID)
<input type="button" value="Filter" onclick="randomNumbers()"/>
</div>
}
Javascript:
<script type="text/javascript">
function randomNumbers() {
// Math.floor(Math.random() * (UpperRange - LowerRange + 1)) + LowerRange; Generate within a range
var str = Math.floor(Math.random()*100);
document.getElementById('TrackingID') = str;
}
</script>
Please help me.
Regards,
Shomen
Reply
Answers (
2
)
Config Settings in web.config
ping source cod in asp.net