|
RTFM. You probably need to Stop() the timer before you start it again or something like that.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
aslesh wrote: If you know the syntax for the timer that will be a gr8 help for me
aslesh wrote: I tried with the syntax you have given. but the thing is for the first time its taking the time interval correct ( here i gave it as 5 sec).but, when i agian changing the text then its holding for only 2.5 sec and then if i do it for 4 to 5 times its displaying instantly.
Maybe you should just go to his location and do the work for him I bet that would be a gr8 help for him.
led mike
|
|
|
|
|
I am new to .net programming, so please pardon any mistakes I make. On my page have gridview1 and inside the edit template of the gridview1 have texbox8. When the user clicks on the edit button the textox8 should automatically populate current machine date. I am not sure how to access the texbox8 inside the gridview and display the current date.
Following is the part of the code:
<asp:gridview id="GridView1" runat="server" allowpaging="True" xmlns:asp="#unknown">
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource1" Height="369px" Width="482px"
Font-Names="Arial" Font-Size="8pt" ForeColor="#333333" GridLines="None"
PageSize="30"
<edititemtemplate>
<asp:textbox id="TextBox4" runat="server" height="15px">
Text='<%# Bind("ClosedDate", "{0}") %>' Width="60px"
ontextchanged="TextBox4_TextChanged">
<cc1:calendarextender id="TextBox4_CalendarExtender" runat="server" xmlns:cc1="#unknown">
Enabled="True" TargetControlID="TextBox4">
/GridView1>
Here is the code in my .vb file:
Protected Sub TextBox4_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
For Each row In GVOpenNCMR.Rows
Dim textBoxText As = (CType(row.FindControl("TextBox4"), TextBox)).Text
Next
End Sub
Not sure where to put the code for the textbox to populate system date. Anyhelp would be appreciated. Thanks.
|
|
|
|
|
If you're new to .NET, why are you working on something so complex ? And why is your textbox called textbox8 ?
RuhrT wrote: For Each row In GVOpenNCMR.Rows
Dim textBoxText As = (CType(row.FindControl("TextBox4"), TextBox)).Text
Next
This is a mess. You don't need to do this, sender is TextBox4, you just need to cast it. But, either way, what are you trying to do here ? And why send a postback every time the text is changed ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I am trying to populate the textbox with today's date as soon as the user clicks on the edit button of the gridview. I have to find that control in the gridview first and that's what below code is doing.
Dim textBoxText As = (CType(row.FindControl("TextBox4"), TextBox)).Text //Looking for the textbox inside the gridview.
|
|
|
|
|
But it does it in the text changed event. why do you want to replace the text they just entered ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
*sigh* another person who asks questions and runs away when people try to help....
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I can't help you if you don't respond.....
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hello,
I have this CheckBoxList that is connected to a database table. If an item is selected - the values in the table are deleted, then re-inserted with new values, depending on the current selections. However, It works if I make a new selection. If I deselect an existing selection - it refuses to deselect it. So, apparently, the problem is with selecting/deselecting.
If I'd use CheckBoxes instead of the list, it would work fine
Here are some of my code:
<br />
for (n = 0; n < cblRole.Items.Count; n++)<br />
{<br />
if (cblRole.Items[n].Selected)<br />
arr[n] = 1;<br />
}<br />
So, before doing the above, first I need to identify which listitem was clicked - because, the sender is the CheckBoxList itself, not the items.
Thanks.
|
|
|
|
|
There's no SelectedItem property ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Yes, I tried SelectedIndex property...but its doing the same thing.
May be I'm missing something or trying the wrong way. I tried this:
<br />
for (n = 0; n < cblRole.Items.Count; n++)<br />
{<br />
if (n == cblRole.SelectedIndex)<br />
arr[n] = 1;<br />
else<br />
arr[n] = 0;<br />
}<br />
|
|
|
|
|
Gosh - why not just set the selected index to 1 ? What happens when you debug it ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Sorry, may be I was not able to explain to you clearly.
I'm not clear why you said to set SlectedIndex to 1. What do I achieve by doing that?
These are a group of checkboxes and by using the loop, I wanted to identify the ones selected by storing 1 in the array, that I intended to use later.
Anyway, my problem is with selection/deselection. when a checkbox is clicked, how do I know it is selected or deselected (because I can't use the sender).
Thanks.
|
|
|
|
|
The CheckBoxList control returns only the first SelectedIndex. And since it is not an Array you must
check all Items.
foreach (ListItem item in cblRole.Items)
{
if (item.Checked)
{
}
}
|
|
|
|
|
Thanks digimanus and Christian.
I definitely tried this. What's happening is - the checkboxes are checked depending on values in a database table. When they make a new selection, it's suppossed to save the change in the database - then reflect the change in the checkboxes. My code works one way. If they make a new selection, it shows the checkbox as selected. If they deselect one, it doesn't work. It keeps the box as selected. So, I was thinking - it's a problem with the selection/desection.
But now feels like It's something else.
I'll review my code and come back.
Thanks again.
|
|
|
|
|
I have a CustomValidator control which is declared like this:
<br />
<asp:CustomValidator ID="m_DelayCodeValidator" runat="server"<br />
ControlToValidate="m_DelayCode" Text="*" ErrorMessage="Delay code"<br />
EnableClientScript="true"<br />
ClientValidationFunction="m_DelayCode_Validate" <br />
OnServerValidate="m_DelayCode_Validate" /><br />
I have a ValidationSummary control on the page as well. But when I try and submit the form the error message from my custom validator isn't listed with the other error messages in the ValidationSummary. The custom validation script isn't being called either - the script is only called when the value of ControlToValidate changes. I need the script called on submit as well like the other validators are.
ValidationSummary:
<asp:ValidationSummary ID="validationSummary" runat="server" DisplayMode="BulletList"<br />
HeaderText="Please enter the required values:" /><br />
ClientValidationFunction:
function m_DelayCode_Validate(sender, args)<br />
{<br />
if(m_DowntimeCode.options[m_DowntimeCode.selectedIndex].text != "Opportunity Maintenance")<br />
{<br />
args.IsValid = true;<br />
return;<br />
}<br />
<br />
if(args.Value == "" || args.Value == null || args.Value == undefined)<br />
args.IsValid = false;<br />
else<br />
args.IsValid = true;<br />
}<br />
|
|
|
|
|
I found the best thing is to dig in to the js that ASP.NET generates, and to write my own method that duplicates their calls but adds my own, if I want that degree of control.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Thanks for your suggestion. It led me to find a property I hadn't noticed as part of the CustomValidator control - ValidateEmptyText. Setting it to true fixes the problem for me. I guess I neglected to mention that the value of the default option was an empty string. I appreciate the help.
|
|
|
|
|
Glad to help
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi, I have the following code that is giving me this error:
An object reference is required for the non-static field, method, or property 'wwwroot_Admin_EditPuppies.PedDetailsView'
Here is the code in question:
<asp:Substitution ID="Substitution1" runat="server" MethodName="GetFilename"; />
and the script:
<script language="C#" runat="server">
static string GetFilename(HttpContext context)
{
int Record = (int)PedDetailsView.SelectedValue;
string file = DetailsView1.Rows[Record].Cells[8].Text.ToString();
Response.WriteFile(file);
}
</script>
Can someone PLEASE HELP me??? I have been trying forever to get this to work!!
|
|
|
|
|
Did you try google, or perhaps one of your C# references ? The error means what it says. You make a method static, and it cannot access instance variables. Why do you have static ? Remove it and it will build.
I NEVER put code in the aspx, that's just ugly and hard to read.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi, yes, I have literally spent hours combing through google searches and multiple forums, as well as all the C# books I have...I tried to take out the static, but it still gives the same error. As far as putting the code in the code behind file, I agree with you! However, every single instance I've found online put the Method for the Substitution in a <script> tag...the one time I did try to put the function in the code behind, I got an error that said it couldn't find the function.
Due to this, I have deduced that the method MUST be static when applied to a substitution control. I am very frustrated, and I really need some help on this issue. Thanks so much for your quick reply!
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">familyof7 wrote:</div>I got an error that said it couldn't find the function.</blockquote>
This would happen if you made it private. Make it public and I don't see how it could not be visible. Even protected would work, I think. It's not really going to change for the compiler that it's in the code behind.
I can't see any reason for it to need to be static. If it does, tho, the object that raised the event is the sender parameter, so cast that instead of grabbing it by name. ( oops, that doesn't work, sorry. It's not an event, and you are not accessing the control itself. I wish I could see the original post when I reply.... )
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
"The callback method that you specify must be a static method on the page or user control that contains the Substitution control."
Well, it looks like it does have to be static, which probably means you can't use it to do what you're trying to do. Unless your page will only ever have one user at a time, otherwise, I see no way out of it.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Yeah, I was thinking that too...could i use an iframe to display the excel file? I still have to get the filename from the database...let me try it this way and hopefully I'll get it working...
|
|
|
|