|
Hi all,
I using MessageString method to calculate the string width. It is not giving the proper String Width.
Eg:
Font = "Arial 8.25";
Font.Style = Regular;
string1 = "1234567890123456789012345678901234567890123456789012345678901"
If you place this string to the label/TextBox. The actual width is 368px.
But when i use graphics.MeasureString method it gives 387.9978.
Is there any other method is available to calculate the string / what's the problem in this method.
Some article says, Sometimes MeasureString method will give improper values.
Is it true?
Please tell me if anybody knows...
Thanks.
Thanks & Regards
Kumaran
modified on Monday, July 20, 2009 11:37 PM
|
|
|
|
|
MeasureString actuall gives pixel representation of Actual Graphics Text string. It will be working when you are using a canvas to DrawString. Browser text size is not proper for this. I think the actual pixed depends on each browser.
So very little help you have other than trial - error method to determine the size of the textbox.
Love to see more replies if there is any alternative.
|
|
|
|
|
How to hide the url in popup window.
IN IE6 there is no url but when we view the same popup in ie7 then url is visible on the popup.
|
|
|
|
|
Manprit.bagga wrote: IN IE6 there is no url but when we view the same popup in ie7 then url is visible on the popup
You cannot Hide URL bar in IE7 and above
The same is also applicable to Firebox, Opera, Chrome, etc
|
|
|
|
|
Standard window.Open doesnt allow to hide your url. There is I think no support to hiding address in IE 7 or later.
|
|
|
|
|
hi all ,
i use this code in codebehind
if (Session["LoginID"] != null)
{
lblLoginId.Text = Session["LoginID"].ToString();
}
now i just want "Session["LoginID"]" or lblLoginId.Text from javascript
how is it possible?
thanks
|
|
|
|
|
You can not access Session object in Javascript as it is a Server object.
Here [^]is a nice article explaining how to write client side variables in ASP.Net
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
zeeShan anSari wrote: now i just want "Session["LoginID"]" or lblLoginId.Text from javascript
If you are trying to access lblLoginId.Text from client side, then what is need of session over here. You can try just using reading the ClientID of that control.
You can't Directly Access Session Variable from javascript. You can store it in a hiddenField and then can access from Client Side.
|
|
|
|
|
thanks...
but when i store it in a hiddenField then i use runat=server .......so it can't accessible in javascript. or if use hiddenField witout runat=server then it can't accessible in codebehind.......
so what i do?
|
|
|
|
|
zeeShan anSari wrote: but when i store it in a hiddenField then i use runat=server .......so it can't accessible in javascript. or if use hiddenField witout runat=server then it can't accessible in codebehind.......
Leave it as Runat="Server"
Then
var HiddenFieldID="<%=hdnField.ClientID%>";
var HiddenFieldValue=document.getElementById(HiddenFieldID).value;
|
|
|
|
|
There are Two ways
1. Using Classic Asp Tag to fetch the Session Variable
var cal = <%= Session("LoginID") %>
2. You can make a AJAX call to server to fetch the Value stored in Session Variable
|
|
|
|
|
Try this -
var lgnId= '<%=Session["LoginId"]%>'
|
|
|
|
|
no,no,no,no.......
I have seen this code in a couple of dozen posts and it NEVER works.
My situation
ASP .NET 3.5
C# code doc.aspx.cs
...
...
Session["UID"] = "1234";
Javascript doc.aspx
var uid = <%=Session("IUD")%> NO
var uid = '<%=Session("IUD")%>' NO
var uid = "<%=Session("IUD")%> NO
var uid = <%=Session([IUD"]%> NO
var uid = '<%=Session["IUD"]%>' NO
var uid = "<%=Session["IUD"]%>" NO
I think the code below would work but I'm not sure how to code the client side
C# code
HiddenField hUID.value = Session["UID"];
Javascript
????????????????
I'm pretty frustrated after several hours of trying to get this to work. A working example of code would be HIGHLY appreciated.
Thanks,
Joe B
|
|
|
|
|
I want to hide the cursor or make the blinking cursor stop blinking in the asp.net textbox. Is that possible??
|
|
|
|
|
You cannot hide the cursor. If you have set the ReadOnly=True then it will not not let user write anything. But cursor blinking will appear by default. Alternatively you can set the property TabStop=False. Then cursor will not appear by default in Rich text Box. But if you click in the Rich Text Box the cursor wil blink. But it will not let user edit as you have set ReadOnly=True
|
|
|
|
|
no normal HTML input text cant do. Well, why not u use Span to do that, when user types in the document, just update the span. This way you can only do this, but I dont think it is a better option to do.
Otherwise you can hide cursor if the textbox is within a Flash object.
|
|
|
|
|
Hello,
I am having two textboxe's i.e Credit and Debit.
I want to validate the textbox so that only must be entered i.e either
credit or debit.
If the both the textboxe's are filled it must raise a validation
that only must be filled.
plz help me how to validate these textboxe's
Thanks in advance
|
|
|
|
|
Hi,
u can do from client side,
function fnnotnull()
{
if ((document.GetelementId("<%= txtCredit.ClientID %>").value <> "") && (document.GetelementId("<%= txtdebit.ClientID %>").value <> ""))
{
alert("Msg here");
return false;
}
}
u can call this in a button onclientclick event
regards,
kannak....
kannak
|
|
|
|
|
I guess, you directly write the code over here
Small Correction,
sekannak wrote: GetelementId(
getElementById
|
|
|
|
|
As an improvement to this, you may want to wrap this javascript into a custom validator and include server side validation also.
|
|
|
|
|
Any one plz help me how to bind Gridview inside the Listview control
|
|
|
|
|
Hi,
U mean,inside Gridview, Listbox is a Itemtemplate...
page_load()
{
u have to create the function as a dataset, within the function u have to take the id,text from the query.
}
DesingView:
Then u have to call the function like,
<asp:listbox datasource="<%# fnPopulateDropDownListSpl() %>" datatextfield="textfield" datavaluefield="ValueField">
regards,
kannak....
kannak
|
|
|
|
|
Thanks,
That's ok. If i bind the gridview to inside the listview control how it will work?
It's like expand and collaspe button modal.
|
|
|
|
|
Insert a Grid View in item Template of ListView view below code
The code is tested .
<asp:ListView ID="ListView1" runat="server"
onitemdatabound="ListView1_ItemDataBound1">
<LayoutTemplate>
<table border="0" cellpadding="3" cellspacing="0" width="97%">
<tr class="lstheader">
<td width="15%">
Col one</td>
<td width="15%">
Grid Column</td>
</tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr >
<td>
<asp:Label ID="lblDate" runat="server" Text='<%#Bind("DepartmentID") %>'></asp:Label>
</td>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Department" DataField="Department" />
</Columns>
</asp:GridView>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr >
<td>
<asp:Label ID="lblDate" runat="server" Text='<%#Bind("DepartmentID") %>'></asp:Label>
</td>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Department" DataField="Department" />
</Columns>
</asp:GridView>
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
now firstly Bind the ListView Control as below
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillgrid();
clsDepartment dpt = new clsDepartment();
ListView1.DataSource = dpt.SelectAll();
ListView1.DataBind();
}
}
Implement the ItemDataBound event of ListView and Find The Gridview. After Finding bind it
protected void ListView1_ItemDataBound1(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
GridView Grd = e.Item.FindControl("GridView1") as GridView;
if (Grd != null)
{
clsDepartment dpt = new clsDepartment();
Grd.DataSource = dpt.SelectAll();
Grd.DataBind();
}
}
}
|
|
|
|
|
It's working fine. Thanks.
I need to expand and collapse the ID (Department-ID) the department details will be display in gridview or (listview).
Plz help me....
Thanks.
|
|
|
|