|
Tridip Bhattacharjee wrote: i want to generate a div dynamically
You can create a new div, or other way you can have a div design time in display:none state,Now whenever you require,just change the display property and set the top and left property and also height and width.
For that you require , the position of the multiline textbox ( which renders as textarea) and set it to the div.
|
|
|
|
|
thanks for reply but it would be better if u provide some code for my requirement.
thanks.
tbhattacharjee
|
|
|
|
|
The below code gives you the position of an object passed
function findPosition(obj)
{
var curleft = curtop = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
}
return [curleft,curtop];
}
pass the DOM object to findPosition and get the position of the textarea.
Now set the top and left with this position.
Also set the width and height of the div as your textarea.
|
|
|
|
|
Hi, every one. I am new in MVC and just practicing to improve my knowledge.I have the following codes and trying to pass data to GridView. but I get error after running the page.
Its my PersonController
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MvcApplication1.ViewModels;
using MvcApplication1.Models;
namespace MvcApplication1.Controllers
{
public class PersonController : Controller
{
HostelEntities1 HostelDB = new HostelEntities1();
public ActionResult Index()
{
var Persons = from peson in HostelDB.Person_prs
select peson.fname_prs;
var ViewModel = new PersonIndexViewModel
{
Person = Persons.ToList(),
NumberOfPeople= Persons.Count()
};
return View(ViewModel);
}
}
}
Its my ViewModel Class. I have class called PersonIndexViewModel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcApplication1.ViewModels
{
public class PersonIndexViewModel
{
public int NumberOfPeople { set; get; }
public List<string> Person { set; get; }
}
}
and finally in View folder I have the following code
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.ViewModels.PersonIndexViewModel>" %>
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<script type="text/C#" runat=server>
protected void Page_Load(object sender, EventArgs e)
{
this.GridView1.DataSource = this.Model.Person;
this.GridView1.DataBind();
}
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>This Page List Name Of People</h2>
<p>select from<%=Model.NumberOfPeople%></p>
<ul>
<%foreach (string NamePeople in Model.Person)
{ %>
<li>
<%=NamePeople%>
</li>
<%} %>
</ul>
<asp:GridView ID="GridView1" runat="server" Width="50%" EnableViewState="False"
DataSourceID="EntityDataSource1">
</asp:GridView>
<asp:EntityDataSource ID="EntityDataSource1" runat="server">
</asp:EntityDataSource>
</asp:Content>
after running I face with this error
<br />
Control 'ctl00_MainContent_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.<br />
Could yo please help me out.
modified on Sunday, November 14, 2010 8:15 AM
|
|
|
|
|
|
Relatively new to asp.net. I want to develop a page that uses an AJAX Tab Panel Control. Based on the tab, the user selects, a filter is applied to the result set shown on a grid. I'm wondering if I should just have the tabs display without showing anything in the tab itself, or develop a custom control (.ascx) which I would include on the tab, thus I'm writing code once instead of having a unique grid on every tab.
If I use the custom control and have the grid on the tab, how do I access controls on the .aspx page? Simple example. I have a label on the .aspx page which displays messages, based on what someone is doing on the grid. If the grid is in the .ascx, how do I access the label in the .aspx?
|
|
|
|
|
Just wonder is it a good practice to host web site and web services in the same app pool and same virtual directory ?.
The asp.net web site will call the business facade directly and the web services will host the business facade for others .net application.
|
|
|
|
|
kakarato wrote: Just wonder is it a good practice to host web site and web services in the same app pool and same virtual directory
It's better if assign both web services and web application, different application pool.Because if you are consuming your web services from multiple applications, then if your app pool gets down due to web application problem, your webservices will also be down. And rest other other application will not be able to use it.
But if webservices is just consumed by one application, then you can deploy in same application pool
|
|
|
|
|
Hi All,
I am using asp.net MVC 2 and am having an issue running two getJSON commands at the same time.
However I try to re-arange the code the second one waits for the first one to finish before runnning. Consider this code as an example.
var InProgress = false;
function Start(){
InProgress = true;
DoSomething();
UpdateProgress();
}
function DoSomething(){
$.getJSON("url", {}, function(data){
InProgress = false;
$("#text").text("Complete");
});
}
function UpdateProgress(){
if(InProgress){
$.getJSON("url2", {}, function(data){
$("#text").text(data.Percent);
setInterval(UpdateProgress(), 500);
}
}
}
Basically, I am trying to get a progress report for the main process.
What is happening is...
Start() called
UpdateProgress() called
text updated
DoSomething() called
UpdateProgress() called (But only after DoSomething getJSON has finished)
The whole process runs for about 5 - 10 seconds so UpdateProgress should be called many more times.
Can anyone help with why this would happen? I cannot find anything on the web to help me out
Thanks
EDIT
--------
I have found what the problem is. I was using Session (assigning the progress value to) in the Actions that the getJSON commands called. And for some reason this was forcing the second getJSON to wait. Removed session references, problem fixed.
However my problem now is, what do I use instead of Session. I basically need to persist a variable value across multiple action calls. I understand that essentially for two action to run together then they must be on different threads somewhere along the line. So I guess that is the issue.
Any idea's cleaver people?
Life goes very fast. Tomorrow, today is already yesterday.
modified on Friday, November 12, 2010 11:54 AM
|
|
|
|
|
i found a serious problem that when i click on button then postback happen but i stopped the postback.
my code is follows. please see what is wrong in it.
-----------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function ShowDiv()
{
var modalWindow = document.createElement('div');
modalWindow.style.position = 'absolute';
modalWindow.style.height = '100px';
modalWindow.style.width = '100px';
modalWindow.style.left = (modalWindow.style.height - getDocHeight())/2;
modalWindow.style.top = (modalWindow.style.width - getDocWidth())/2;
modalWindow.style.backgroundColor = '#C0C0C0';
modalWindow.innerHTML = 'hello...';
document.body.appendChild(modalWindow);
return false;
}
function getDocHeight()
{
return Math.max(document.getElementById('TextBox1').style.height );
}
function getDocWidth()
{
return Math.max(document.getElementById('TextBox1').style.width );
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Style="left: 745px; position: relative;
top: 298px" Text="Button" OnClientClick=" return ShowDiv()" />
<asp:TextBox ID="TextBox1" runat="server" Height="180px" Style="left: 307px; position: relative;
top: 264px" TextMode="MultiLine" Width="432px"></asp:TextBox></div>
</form>
</body>
</html>
here ShowDiv() function return false. another thing i notice that when i comment all the line in function ShowDiv() then postback is not happening. i just do not understand if i generate a div and add to page from javascript then why postback happening.
please tell me the solution to avoid postback when i will generate div from any function. if possible please rectify my code.
thanks
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: another thing i notice that when i comment all the line in function ShowDiv() then postback is not happening.
This is happening because there is an error in your code. Once there is an error, return false; is not getting executed, that's why postback occurs.
The error is in lines
modalWindow.style.left = (modalWindow.style.height - getDocHeight())/2; modalWindow.style.top = (modalWindow.style.width - getDocWidth())/2;
here you are trying to like 180px-100px , so this is throwing an error. Get the height, remove px from the height then try, it will work
|
|
|
|
|
thanks a lot.
tbhattacharjee
|
|
|
|
|
Your welcome
|
|
|
|
|
Because of Masterpage's heaving occupying space, it is difficult to design content pages.
Is it possible to switch content page w/t or without MasterPage in DesignView.
|
|
|
|
|
I don't think, there is any way.
But another way you can do, create a page without master page, do your designing and and at last, change the page to content page.
|
|
|
|
|
No , its not possible, mybe what you can do , create a Master page and dont do anything to it, just add content pages and start working and you will have a lot of space. When you are done , then link it with the final master page
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
hi guys. i have strange bug or problem with this two controls. i will simplify my code as much as i can.
i have this markup:
<asp:FormView ID="fv" runat="server" DataSourceID="sds" DataKeyNames="id">
</asp:FormView>
<asp:DetailsView ID="dv" runat="server" DataSourceID="sds" DataKeyNames="id">
</asp:DetailsView>
<asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
ProviderName="System.Data.OleDb" SelectCommand="SELECT * FROM [tablica]" >
</asp:SqlDataSource>
and lets say i need on first PageLoad get SelectedValue from eather of these:
protected void Page_Load(object sender, EventArgs e)
{
object fvValue = fv.SelectedValue;
object dvValue = dv.SelectedValue;
}
so here is strange situation (looks like evil bug!). fvValue and dvValue have null value, but debuging code using Visual Studio with brakepoints; when i collapse fv or dv and navigate to SelectedValue property it changes from null to "something"?
anyone encounter this situation?
|
|
|
|
|
I have a page which does an upload functionality. Once it is uploaded successfully, I should be able to go to the third step of a Wizard control in another page. Is it possible to do so? Could anybody please help me on this? Any links or tutorials is fine.
Thanks in advance
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
If you are using the ASP.NET Wizard control then you should be able to set the ActiveStepIndex to the appropriate page.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thank you for the reply.
I am using ASP.Net Wizard Control only. But I need to come frome another page to the Wizard page. For eg. I have two pages, a.apx and b.aspx. Assume that Wizard controlis in b.aspx and Upload functionality in a.aspx. Once the upload becomes successful in a.aspx,I should be able to navigate to the 2nd or 3rd step of Wizard Control in b.aspx. Is this possible in Wizard Control?
Is it possible to write something like FindControl in a.aspx by referring the b.aspx page and setting the activestepindex in a.aspx itself so that it directly come to the 2nd or 3rd step of Wizard control in b.aspx?
Thanks
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I think you need to stop and think a bit, and learn/understand the asp.net model.
You can't find a control on page b from page because it doesn't exist until the page is served.
What you can do is pass the data to set the wizard from page a to page b via query string or session variable. Then in your page load event set the wizard property appropriately. This is basic ASP.NET development.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
What are industry standards on customizing a product to fit your needs, such as aspdotnetstorefront? Changes may include source code change, database structure changes, etc. When there is any upgrade to the product, it should be smooth process w/o loosing the customizations.
|
|
|
|
|
how to show busy indicator in the center of multiline textbox control when user click on button. when i am using MS-Ajax and multiline textbox & button in update panel then i need when user write something in textbox and click button for submitting it then a busy indicator will show just at the center of that multi line textbox. i have seen this type of effect in MSDN forum. can anyone help me with sample code.
thanks
tbhattacharjee
|
|
|
|
|
You can't add a control to the textbox, what is most likely happening is a div containing the progress indicator is floated over the textbox. You can use javaScript to asertain the positions and widths to position it correctly.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
thanks but it will be better if u give me that kind of code to simulate the situation.
tbhattacharjee
|
|
|
|